headers not added in preflight-requests (OPTIONS)
See original GitHub issueI’m using the proxy option to proxy requests to my API. Additionally I did setup the following headers:
headers: {
'Access-Control-Allow-Origin': '*'
}
The header is only set in GET, POST etc. requests, but not on preflight requests, that yields to an error in Chrome:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 403. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Is it possible to add a request header to a CORS preflight ...
The CORS preflight OPTIONS request is totally controlled by the browser; so it's not possible to add request headers to it.
Read more >Preflight request - MDN Web Docs Glossary: Definitions of ...
It is an OPTIONS request, using three HTTP request headers: Access-Control-Request-Method , Access-Control-Request-Headers , and the Origin ...
Read more >Chapter 4. Handling preflight requests - CORS in Action
The previous chapter showed how to respond to CORS requests by using the Access-Control-Allow-Origin header. While this header is required on all valid...
Read more >Cross-Origin Resource Sharing and Why We Need Preflight ...
Any request which is not a simple request is considered a non-simple or a preflighted request. The browser treats these kinds of requests...
Read more >How to skip CORS preflights and speed up your API with polyfills
To mitigate the risk to old applications, an extra "preflight" request was added to requests with PATCH, PUT, DELETE methods, and to requests ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi, you can try this config if anybody meet the same problem
localhost:3101 is koa server, webpack dev server is localhost:8888.
How to test:
1.Preflighted_requests
2.The real POST request, you can get koa server response data
options能通过了,post显示404 not found怎么处理呀大佬