Skip to content

How does Nuxt initiate cross-domain resource requests? How does nuxt+vue+axios configure proxy forwarding (nuxt.config.js) #131

Answered by hixb
xiao-ice asked this question in Q&A
Discussion options

You must be logged in to vote

How does Nuxt initiate cross-domain resource requests? How does nuxt+vue+axios configure proxy forwarding (nuxt.config.js)

`
const {

API_SERVER = 'http://youguolocal.testin.cn',

NODE_ENV = 'dev'

} = process.env;

module.exports = {

axios: {

proxy: true

},

proxy: {

'/dsp': {

target: API_SERVER,

onProxyRes(proxyRes) {

proxyRes.headers['content-type'] = 'application/json';

} }

},

'/ssp': {

target: API_SERVER,

onProxyRes(proxyRes) {

proxyRes.headers['content-type'] = 'application/json';

} }

} }

} }

}

In this way, when we run the project, if there is a /ssp request link in the root directory, it will be forwarded to API_SERVER (the default setting is http://youguolocal.testin.cn). If there is…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by xiao-ice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants