How to ask axios.baseUrl in Nuxt that would work on LAN and on the domain?

Good day! Originally was like this:
axios: {
 baseURL: process.env.NODE_ENV === 'production'
 ? ''
 : 'http://localhost:3000'

My joy knew no bounds, until I went to and found that the queries go to your domain without www and blocked CORS policy => a domain with www is down.
Then tried:
axios: {
 baseURL: '/'

But here, the time - code from nuxtServerInit ceases to work correctly.
async nuxtServerInit({ dispatch, getters, commit }) {
 const isUserSigned = await dispatch('auth/autoSignin');

 if (isUserSigned) await dispatch('auth/getUserByToken');

async getUserByToken({commit, dispatch}) {
 try {
 const user = await this.$axios.$get('/api/auth/getUserByToken');

 if (user && {
 dispatch('setUser', user);
 } else {
 dispatch('signout', false);

 } catch (e) {
 dispatch('setUser', null);
 dispatch('signout', false);

That is, the response from the server 404, because the request is sent to http:/api/auth/getUserByToken' (literally).
With the other queries, everything is in order, at least until that problem is relevant only for nuxtServerInit.

What would you recommend?
April 3rd 20 at 18:54
0 answer

Find more questions by tags Vue.jsNuxt.js