Address problem of nuxt request backend

request the backend address in nuxt, for example, I want to send post data to the server (the server out of the interface is a separate project)

in the local development environment, I want to send it to localhost:5000 (the project of nuxt is localhost 3000)

in the test environment, I want to send it to test.a.com

in a formal environment, I want to send it to a.com

but when using axios request, I want to use relative address. / api, can avoid cross-domain problems. How to configure

I found @ nuxt/proxy, on the Internet but didn"t know how to distinguish the environment. (I don"t know whether this component is only used for development or can be used online.)

at the same time, I would like to ask nuxt how to distinguish between environments (development, testing, formal)

Mar.28,2021

you can create an app_config.js configuration file in the project, write the address of your environment in it, and then reference the configuration file in index.html, similar to the following
app_config.js location:

staticindex.html

app_config.js content

const idcUrlConfig = {
  //baseIdc: 'http://abc.com'
  baseIdc: 'http://127.0.0.1:8000'
  }

axios reference:

axios.defaults.baseURL = idcUrlConfig.baseIdc

index.html:

<script type="text/javascript" src="/static/app_config.js"></script>

get it done

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9f9c2-1a6f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9f9c2-1a6f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?