Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lib stopped working suddenly, with a Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response. #251

Closed
jonit-dev opened this issue Oct 20, 2021 · 0 comments

Comments

@jonit-dev
Copy link

jonit-dev commented Oct 20, 2021

Hey folks,

I have been using this for a long time (years), and out of nowhere I started having the following issue in production only:

 Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

My temporary solution was adding a custom CORS middleware with the following config.

   res.setHeader("Access-Control-Allow-Origin", "*");
     res.setHeader(
       "Access-Control-Allow-Methods",
       "POST,GET,OPTIONS,PUT,DELETE"
     );
     res.setHeader(
       "Access-Control-Allow-Headers",
       "Content-Type,Accept,Authorization"
     );

     next();

I hope they investigate the issue, since this lib is awesome and saved me ton of hours of CORS related headache

PS:

I was using it like I always did, with a:

app.use(cors()); 

I've tried to edit allowedHeaders with the options that I used above, also also tried

app.options("*", cors());

But nothing seemed to make any difference at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant