Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ async function bootstrap() {
app.useGlobalPipes(new ValidationPipe());
app.setGlobalPrefix('api');

// 配置CORS
app.enableCors({
origin: '*', // 允许所有来源
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', // 允许的HTTP方法
credentials: true, // 允许携带凭证(如cookies)
allowedHeaders: 'Content-Type,Authorization', // 允许的头部字段
exposedHeaders: 'Content-Type,Authorization', // 暴露的头部字段
maxAge: 3600, // 预检请求的缓存时间,单位为秒
});

await app.listen(PORT);
console.log('正在监听端口:', PORT);
} catch (error) {
Expand Down