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请求