fix: change cors

This commit is contained in:
xion 2024-10-18 01:26:04 +08:00
parent 041432baea
commit 6f0faba703
2 changed files with 2 additions and 1 deletions

View File

@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package",
"name": "@kevisual/router",
"version": "0.0.2",
"version": "0.0.3",
"description": "",
"main": "dist/index.js",
"module": "dist/index.js",

View File

@ -80,6 +80,7 @@ export class Server {
res.setHeader('Content-Type', 'application/json; charset=utf-8');
if (cors) {
res.setHeader('Access-Control-Allow-Origin', cors?.origin || '*'); // 允许所有域名的请求访问,可以根据需要设置具体的域名
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
if (req.method === 'OPTIONS') {
res.end();