From 86179443de24953318f0148afc850584ea527363 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 5 Sep 2022 00:27:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9D=99=E6=80=81=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=A2=9E=E5=8A=A0=E5=85=81=E8=AE=B8=E8=B7=A8?= =?UTF-8?q?=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/services/core/gateway.service.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/services/core/gateway.service.ts b/server/services/core/gateway.service.ts index 687c40ce..c4646b90 100644 --- a/server/services/core/gateway.service.ts +++ b/server/services/core/gateway.service.ts @@ -290,7 +290,13 @@ export default class ApiService extends TcService { path: '/', authentication: false, authorization: false, - use: [serve('public', {})], + use: [ + serve('public', { + setHeaders(res: ServerResponse, path: string, stat: any) { + res.setHeader('Access-Control-Allow-Origin', '*'); // 允许跨域 + }, + }), + ], onError(req: IncomingMessage, res: ServerResponse, err) { if ( String(req.method).toLowerCase() === 'get' && // get请求