update cors

This commit is contained in:
2024-10-13 14:22:05 +07:00
parent bf2b361aaf
commit 56c11a4b77
4 changed files with 7 additions and 11 deletions

View File

@@ -14,7 +14,7 @@ services:
- DATABASE_URL=postgresql://your_username:your_password@10.0.27.1:5432/epess - DATABASE_URL=postgresql://your_username:your_password@10.0.27.1:5432/epess
- CLERK_PUBLISHABLE_KEY=pk_test_aW4tY2hpbXAtOTcuY2xlcmsuYWNjb3VudHMuZGV2JA - CLERK_PUBLISHABLE_KEY=pk_test_aW4tY2hpbXAtOTcuY2xlcmsuYWNjb3VudHMuZGV2JA
- CLERK_SECRET_KEY=sk_test_sA5lsb1GHwUNXWQCp5ev70QkaoF5EmdAHNWiCGwZF6 - CLERK_SECRET_KEY=sk_test_sA5lsb1GHwUNXWQCp5ev70QkaoF5EmdAHNWiCGwZF6
- CORS_ORIGIN=http://epess.org - CORS_ORIGIN=http://localhost:3000
- LISTEN_PORT=3069 - LISTEN_PORT=3069
- SWAGGER_PATH=/v1 - SWAGGER_PATH=/v1
labels: labels:

View File

View File

@@ -1,8 +0,0 @@
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
export const cors: CorsOptions = {
origin: process.env.CORS_ORIGIN,
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,
};

View File

@@ -1,11 +1,15 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import { cors } from './common/utils/cors.utils';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.enableCors(cors); app.enableCors({
origin: process.env.CORS_ORIGIN,
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,
});
const config = new DocumentBuilder() const config = new DocumentBuilder()
.setTitle('EPESS API') .setTitle('EPESS API')