close

[Fixed] CORS error :Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response

Today We are Going To Solve CORS error :Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response in javascript. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

How to Fix CORS error :Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response Error?

  1. How to Fix CORS error :Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response Error?

    To Fix CORS error :Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response Error just enable pre-flight request To remove your error you have to just enable pre-flight request by using this code. var express = require('express') var cors = require('cors') var app = express() app.use(cors()) app.options('*', cors()) It will remove your error completely.

  2. CORS error :Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response

    To Fix CORS error :Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response Error just add “Authorization” to allowed headers. To remove your error you have to just add “Authorization” to allowed headers Plugins.Add(new CorsFeature(allowedHeaders: "Content-Type,Authorization"));This will help you!

Solution 1 : enable pre-flight request

To remove your error you have to just enable pre-flight request by using this code.

var express = require('express')
var cors = require('cors')
var app = express()
app.use(cors())
app.options('*', cors())

It will remove your error completely.

Solution 2 : add “Authorization” to allowed headers

To remove your error you have to just add “Authorization” to allowed headers

Plugins.Add(new CorsFeature(allowedHeaders: "Content-Type,Authorization"));

This will help you!

Solution : 3 chnage this

Just change this

<add name="Access-Control-Allow-Headers" value="Content-Type" />

to

<add name="Access-Control-Allow-Headers" value="*" />

This will solve your error.

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read This Solutions

Leave a Comment