251120:1700 Backend T3.4

This commit is contained in:
admin
2025-11-20 17:14:15 +07:00
parent 859475b9f0
commit 20c0f51e2a
42 changed files with 1818 additions and 10 deletions

View File

@@ -3,10 +3,20 @@ import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { TransformInterceptor } from './common/interceptors/transform.interceptor.js'; // อย่าลืม .js ถ้าใช้ ESM
import { HttpExceptionFilter } from './common/exceptions/http-exception.filter.js';
import helmet from 'helmet'; // <--- Import Helmet
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// 🛡️ 1. เปิดใช้งาน Helmet (Security Headers)
app.use(helmet());
// 🛡️ 2. เปิดใช้งาน CORS (เพื่อให้ Frontend จากโดเมนอื่นเรียกใช้ได้)
// ใน Production ควรระบุ origin ให้ชัดเจน แทนที่จะเป็น *
app.enableCors({
origin: true, // หรือระบุเช่น ['https://lcbp3.np-dms.work']
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
credentials: true,
});
// 1. Global Prefix (เช่น /api/v1)
app.setGlobalPrefix('api');