Skip to content

Commit

Permalink
feat: cors
Browse files Browse the repository at this point in the history
  • Loading branch information
wlstmd committed Jul 10, 2024
1 parent e6981e1 commit c5d142f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ const port = process.env.PORT || 3030;
async function bootstrap() {
try {
const app = await NestFactory.create(AppModule);

// CORS 설정 수정
app.enableCors({
origin: '*',
methods: ['GET'],
allowedHeaders: 'Content-Type, Accept',
origin: [
'http://sphagetti-front.s3-website.ap-northeast-2.amazonaws.com',
'http://localhost:3000' // 로컬 개발 환경을 위해 추가
],
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
allowedHeaders: 'Content-Type, Accept, Authorization',
credentials: true,
});

app.setGlobalPrefix('/api');

const config = new DocumentBuilder()
Expand All @@ -33,9 +39,11 @@ async function bootstrap() {
module.hot.dispose(() => app.close());
}

console.log(`Listening on port ${port}`);
console.log(`Server is running on http://localhost:${port}`);
console.log(`Swagger documentation is available at http://localhost:${port}/api-docs`);
} catch (error) {
console.error('Error during bootstrap:', error);
}
}
bootstrap();

bootstrap();

0 comments on commit c5d142f

Please sign in to comment.