update cors

This commit is contained in:
2024-10-13 17:12:33 +07:00
parent 26e4b7c689
commit 263ff4e207
7 changed files with 18 additions and 14 deletions

View File

@@ -6,7 +6,7 @@ import {
Inject,
UnauthorizedException,
} from '@nestjs/common';
import Clerk from '@clerk/clerk-sdk-node';
import Clerk from '@clerk/express';
import { GqlExecutionContext } from '@nestjs/graphql';
@Injectable()

View File

@@ -1,5 +1,5 @@
import { Module, Global } from '@nestjs/common';
import Clerk from '@clerk/clerk-sdk-node';
import Clerk from '@clerk/express';
import { ClerkService } from './clerk.service';
import ClerkController from './clerk.controller';
@Global()

View File

@@ -7,8 +7,7 @@ import {
} from '@smatch-corp/nestjs-pothos';
import { Builder } from '../Graphql/graphql.builder';
import { PrismaService } from '../Prisma/prisma.service';
import { clerkClient } from '@clerk/clerk-sdk-node';
import { clerkClient } from '@clerk/express';
@Injectable()
export class UserSchema extends PothosSchema {
constructor(

View File

@@ -4,8 +4,10 @@ import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const corsOrigin = (process.env.CORS_ORIGIN ?? '').split(','); // split by comma to array
app.enableCors({
origin: process.env.CORS_ORIGIN,
origin: corsOrigin,
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,