What is the reason for the error: Request header field access-tokens-url is not allowed by Access-Control-Allow-Headers in preflight response?
I keep getting CORS errors saying access-tokens-url isn't allowed
, when it's needed.
What am I doing wrong?
The same URL with the same header information works in Postman. Yet I get below errors when I add it to my React UI with axios
.
const url = "https://login.esso-uat.server.com
const config = {
headers: {
"access-tokens-url": "https://some-access-url",
}
await axios.get(url, config)
.then((res)=>{console.log(res)}
Error with this code:
Access to XMLHttpRequest at 'https://obfuscated_the_url' from origin 'http://localhost:3000' has been blocked by CORS policy: Request header field access-tokens-url is not allowed by Access-Control-Allow-Headers in preflight response.
Error without the access-tokens-url
:
AxiosError {message: 'Request failed with status code 401', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …}
Comments
Post a Comment