Skip to content

Commit

Permalink
Added cors for local development
Browse files Browse the repository at this point in the history
  • Loading branch information
moiskillnadne committed Oct 30, 2024
1 parent 88f1567 commit 5d91b99
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import '~/integration/Sentry';

import * as Sentry from '@sentry/node';
import cookieParser from 'cookie-parser';
import cors from 'cors';
import express, { Request, Response } from 'express';
import helmet from 'helmet';

Expand Down Expand Up @@ -35,6 +36,20 @@ process.on('unhandledRejection', (reason: unknown) => {
const app = express();
const PORT = Env.APP_PORT || 3000;

if (Env.APP_ENV === 'local') {
app.use(
cors({
origin: [
'https://localhost:3000',
'http://localhost:3000',
'https://localhost:5173',
'http://localhost:5173',
],
credentials: true,
}),
);
}

app.use(helmet());

app.use(express.json({ limit: '10kb' }));
Expand Down

0 comments on commit 5d91b99

Please sign in to comment.