Axios base url plugin
In order for HTTP calls to work on the different environments (local, BFF, deployment URL), a plugin is available for Nuxt. This plugin will make sure that the right base URL is always set in the application. This can be done by checking the URL of the browser.
TIP
Credits to Tai Thien for providing us with this plugin.
First we need to include it in the nuxt config:
javascript
//nuxt.config.js
plugins: [
'./node_modules/@xerius/codey-nuxt-utils/build/plugins/axios-base-url.js',
],
The plugin depends on routing variables to be available within Nuxt, these need to be set in the publicRuntimeConfig:
javascript
//nuxt.config.js
publicRuntimeConfig: {
...routing.getRoutingRuntimeConfig(),
},