diff --git a/middleware/cors.js b/middleware/cors.js index bda2f90..6b94c23 100644 --- a/middleware/cors.js +++ b/middleware/cors.js @@ -11,8 +11,8 @@ export function createCors() { let opts = this.get('cors') if (opts.enabled) { - let origin = req.header('origin') || req.header('referer') || '' - let headers = req.header('access-control-request-headers') + let origin = req.headers['origin'] || req.headers['referer'] || '' + let headers = req.headers['access-control-request-headers'] let { hostname, host, protocol } = parse(origin) if (opts.origin.length && hostname) { @@ -24,7 +24,7 @@ export function createCors() { } } if (pass === false) { - return res.end('') + return (res.body = null) } } if (opts.credentials) { @@ -43,7 +43,7 @@ export function createCors() { } if (req.method === 'OPTIONS') { - return res.end('') + return (res.body = null) } } next() diff --git a/package.json b/package.json index 1950e23..2c27899 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gm5/core", - "version": "2.0.1", + "version": "2.0.2", "type": "module", "description": "Five.js, 一个轻量级的nodejs mvc框架 旨在简单易用, 5分钟即可上手", "author": "yutent ",