35 lines
913 B
TypeScript
35 lines
913 B
TypeScript
import { ValidationPipe } from '@nestjs/common';
|
|
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from './app.module';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule, {
|
|
rawBody: true,
|
|
});
|
|
|
|
const isDev = process.env.NODE_ENV === 'dev';
|
|
const webOrigins = process.env.WEB_ORIGIN?.split(',').map((origin) =>
|
|
origin.trim(),
|
|
) ?? [
|
|
'http://localhost:5173',
|
|
'http://126.dahyeon.us:5173',
|
|
'https://lolympus.dahyeon.us',
|
|
];
|
|
|
|
app.enableCors({
|
|
origin: isDev ? true : webOrigins,
|
|
credentials: true,
|
|
allowedHeaders: ['Authorization', 'Content-Type', 'X-Auth-User-Id'],
|
|
});
|
|
app.useGlobalPipes(
|
|
new ValidationPipe({
|
|
whitelist: true,
|
|
forbidNonWhitelisted: true,
|
|
transform: true,
|
|
transformOptions: { enableImplicitConversion: false },
|
|
}),
|
|
);
|
|
await app.listen(isDev ? 3000 : 10712);
|
|
}
|
|
bootstrap();
|