mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Check if the incoming header is set before applying to the response
This commit is contained in:
parent
06136d9111
commit
2a1075c122
|
@ -48,7 +48,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-Allow-Methods', 'OPTIONS, GET')
|
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET')
|
||||||
// Based on https://github.com/primus/access-control/blob/4cf1bc0e54b086c91e6aa44fb14966fa5ef7549c/index.js#L158
|
// Based on https://github.com/primus/access-control/blob/4cf1bc0e54b086c91e6aa44fb14966fa5ef7549c/index.js#L158
|
||||||
|
if (req.headers['access-control-request-headers']) {
|
||||||
res.setHeader('Access-Control-Allow-Headers', req.headers['access-control-request-headers'])
|
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