You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a simple webpage were I make a GET-Request towards my RestAPI. Without cors it's not working, when I enable cors for all routes it does work for with content-type = text/plain.
I want to use custom headers though and content-type = application/json
so I figured I need to enable cors preflight. But it does not not work if I enable it. My code is structured as follows:
I get a 405 - method not allowed error, which is strange since it works with content-type = text/plain.
Any idea why it's not working? I can provide more details if needed.
The text was updated successfully, but these errors were encountered:
I am not going to make promise to fix your cors issues. But is the 405 the response to the preflight request or to the subsequent request when you have content type application/json.
In most cases a small working example of the issue that can be run be the cors maintainer is helpful in these situations.
Thx for your answer ghinks.
Now that I looked into it, the 405 response is regarding the OPTIONS method in the preflight request.
Shouldn't app.options('*', cors()); enable a method handler for OPTIONS? I will look if I can get a small example running.
I have a simple webpage were I make a GET-Request towards my RestAPI. Without cors it's not working, when I enable cors for all routes it does work for with
content-type = text/plain
.I want to use custom headers though and
content-type = application/json
so I figured I need to enable cors preflight. But it does not not work if I enable it. My code is structured as follows:
I get a
405 - method not allowed
error, which is strange since it works withcontent-type = text/plain
.Any idea why it's not working? I can provide more details if needed.
The text was updated successfully, but these errors were encountered: