mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Fix Access-Control-Request-Method header (#4424)
* Fix Access-Control-Request-Method header * Make OPTIONS request work
This commit is contained in:
parent
f11d3487f6
commit
a411b35508
|
@ -42,9 +42,9 @@ export function addCorsSupport (req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
res.setHeader('Access-Control-Allow-Origin', req.headers.origin)
|
res.setHeader('Access-Control-Allow-Origin', req.headers.origin)
|
||||||
res.setHeader('Access-Control-Request-Method', req.headers.origin)
|
|
||||||
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET')
|
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET')
|
||||||
res.setHeader('Access-Control-Allow-Headers', req.headers.origin)
|
// Based on https://github.com/primus/access-control/blob/4cf1bc0e54b086c91e6aa44fb14966fa5ef7549c/index.js#L158
|
||||||
|
res.setHeader('Access-Control-Allow-Headers', req.headers['access-control-request-headers'])
|
||||||
|
|
||||||
if (req.method === 'OPTIONS') {
|
if (req.method === 'OPTIONS') {
|
||||||
res.writeHead(200)
|
res.writeHead(200)
|
||||||
|
|
Loading…
Reference in a new issue