fix cors with helmet

This commit is contained in:
Maxime Cannoodt 2022-06-30 09:28:49 +02:00
parent 2e98fa7f2d
commit fce084f590
2 changed files with 7 additions and 10 deletions

Binary file not shown.

View File

@ -11,16 +11,13 @@ const prisma = new PrismaClient();
const app: Express = express(); const app: Express = express();
app.use(express.json()); app.use(express.json());
app.use(helmet()); app.use(
helmet({
// Allow CORS in dev mode. crossOriginResourcePolicy: {
if (process.env.ENVIRONMENT == "dev") { policy: process.env.ENVIRONMENT == "dev" ? "cross-origin" : "same-origin",
app.use( },
cors({ })
origin: "*", );
})
);
}
// Apply rate limiting // Apply rate limiting
const postLimiter = rateLimit({ const postLimiter = rateLimit({