nginx deploys vue project error We're sorry but XXX doesn't work properly without JavaScript enabled
I won’t say much about other situations. There are many online
inquiries about nginx configuration problems.
There is such a situation cross-domain problem
vue project configuration file
devServer: {
port: 8090,
proxy: {
"/agsupport": {
target: "http://127.0.0.1:9001",
changeOrigin: true
},
}
}
The corresponding configuration in nginx should be like this, otherwise the above error will be reported
location /agsupport {
proxy_pass http://127.0.0.1:9001;
}
But there is another case of cross-domain configuration
devServer: {
port: 8090,
proxy: {
"/agsupport": {
target: "http://127.0.0.1:9001",
changeOrigin: true,
"pathRewrite": {
"^/agsupport": "/agsupportTest"
}
},
}
}
This kind of appeal configuration in nginx will not take effect, and the above error will be reported,
because agsupport
the actual proxy at this time is http://127.0.0.1:9001/agsupportTest
that nginx should be configured like this
location /agsupport {
proxy_pass http://127.0.0.1:9001/agsupportTest/;
}
solve