Skip to content

Commit

Permalink
feat: enhance CORS configuration for improved security and flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
DenilsonRabelo committed Jan 3, 2025
1 parent 2eee029 commit 7df7793
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { AppModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors();
app.enableCors({
origin: '*',
methods: 'GET, POST, PUT, DELETE, OPTIONS',
allowedHeaders: 'Content-Type, Authorization',
});
await app.listen(3000);
}
bootstrap();
7 changes: 6 additions & 1 deletion vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
{
"src": "/(.*)",
"dest": "dist/main.js",
"methods": ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]
"methods": ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"],
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Headers": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version"
}
}
]
}

0 comments on commit 7df7793

Please sign in to comment.