I m getting this error-
Access to XMLHttpRequest at 'https://4kd2hi3ere.execute-api.us-east-1.amazonaws.com/default/myfirstvuecode' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
how to slove this error please suggest
I'm having the same issue
same here
For me it worked by adding this configuration:
headers: {
'Cache-Control': null,
'X-Requested-With': null,
},
My advice is to have a close look at the accepted headers and requested headers added by default configuration.
By setting them null they get removed from the request or you can set a specific value as requested by the API (eg, Auth bearer token)
headers: {
'Access-Control-Allow-Origin': '*',
"Content-Type": "text/html",
},
For me it worked by adding this configuration:
headers: { 'Cache-Control': null, 'X-Requested-With': null, },My advice is to have a close look at the accepted headers and requested headers added by default configuration.
By setting themnullthey get removed from the request or you can set a specific value as requested by the API (eg, Auth bearer token)
Added the configuration in which file?
For me it worked by adding this configuration:
headers: { 'Cache-Control': null, 'X-Requested-With': null, },My advice is to have a close look at the accepted headers and requested headers added by default configuration.
By setting themnullthey get removed from the request or you can set a specific value as requested by the API (eg, Auth bearer token)Added the configuration in which file?
I assume that this was added to the vue.config.js file?
like so (i've added it all to give it a test run) :
module.exports = {
devServer: {
proxy: 'http://localhost:8080',
headers: {
'Access-Control-Allow-Origin': '*',
'Cache-Control': null,
'X-Requested-With': null,
'Content-Type': 'text/html'
}
}
}
please where i must add :headers: {
'Cache-Control': null,
'X-Requested-With': null,
}, back or front ,I use java as back and angular in front
Most helpful comment
For me it worked by adding this configuration:
My advice is to have a close look at the accepted headers and requested headers added by default configuration.
By setting them
nullthey get removed from the request or you can set a specific value as requested by the API (eg, Auth bearer token)