From 608ee017d4bca2434e176e9bb5531fbc7d87abe0 Mon Sep 17 00:00:00 2001 From: Developer Date: Mon, 18 May 2026 21:41:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=85=8D=E7=BD=AE=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=9F=9F=E5=90=8D=E7=9A=84=E8=B7=A8?= =?UTF-8?q?=E5=9F=9F=20CORS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 servicewechat.com、miniapp-api-test.dxz99wyr.cn、api-miniapp.dxz99wyr.cn 到 CORS origin - 允许 GET/POST/PUT/DELETE/OPTIONS 方法 - 允许 Content-Type/Authorization/Accept/Origin/X-Requested-With 请求头 --- src/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index d7fb99e..5f3c8d9 100644 --- a/src/app.js +++ b/src/app.js @@ -41,7 +41,16 @@ app.use(helmet({ }, }, })); -app.use(cors()); +app.use(cors({ + origin: [ + 'https://servicewechat.com', + 'https://miniapp-api-test.dxz99wyr.cn', + 'https://api-miniapp.dxz99wyr.cn' + ], + methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], + allowedHeaders: ['Content-Type', 'Authorization', 'Accept', 'Origin', 'X-Requested-With'], + credentials: false +})); app.use(express.json({ limit: '10mb' })); app.use(express.urlencoded({ extended: true }));