From 38c79587e20842a362ea292e13cbeb0181c7a192 Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 8 Nov 2023 09:33:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=A8=E5=9F=9F=E4=B8=AD?= =?UTF-8?q?=E9=97=B4=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware/cors.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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 ",