251120:1700 Backend T3.4
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user