Always return 200 for OPTIONS

This commit is contained in:
Marcus Noble 2018-11-14 15:43:30 +00:00
parent 4574e8f4f2
commit de3e7a7e19
1 changed files with 8 additions and 0 deletions

View File

@ -14,6 +14,14 @@ http.createServer((req, response) => {
let remoteURL = url.parse(req.url.substring(1));
if(!remoteURL.hostname || remoteURL.hostname === 'localhost') return response.end();
if(req.method === 'OPTIONS') {
response.writeHead(200, {
'access-control-allow-origin': req.headers.origin || '*',
'access-control-allow-headers': 'Origin, X-Requested-With, Content-Type, Accept, authorization'
});
return response.end();
}
for(let key in req.headers) {
if(key.match(/host|cookie/ig)){
delete req.headers[key];