fix: configure CORS for Vercel frontend domain

This commit is contained in:
lichao 2026-02-25 11:53:44 +00:00
parent ec17b894a6
commit 5f50a97549
1 changed files with 5 additions and 1 deletions

View File

@ -46,7 +46,11 @@ async function bootstrap() {
const configService = app.get(ConfigService); // 获取 ConfigService 实例 const configService = app.get(ConfigService); // 获取 ConfigService 实例
app.enableCors({ app.enableCors({
origin: true, // 允许所有来源 origin: [
'https://tradingadvfrontend.vercel.app',
'http://localhost:8000',
'http://localhost:3030',
], // 明确指定允许的前端域名
credentials: true, // 允许携带凭证 credentials: true, // 允许携带凭证
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'], // 明确指定允许的 HTTP 方法 methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'], // 明确指定允许的 HTTP 方法
allowedHeaders: [ allowedHeaders: [