Problem Description
VUE cannot request correct data when sending the request, the console is as follows
Access to XMLHttpRequest at 'http://localhost:8000/equip_fault_report/all' from origin 'http://localhost:8080' has been
blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The URL in my request js is like this
solution
Write the following in the configuration js
devServer: {
proxy: {
'/api': {
target: 'http://localhost:8000',
changeOrigin: true,
pathRewrite: {
'/api': ''
}
}
}
}
It is interpreted as adding link headers, enabling cross-domain, and adding /api as identification.
It means the link under the request/api, which directly returns to the target
The URL of the request js is as follows