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();
app.use(express.json());
app.use(helmet());
// Allow CORS in dev mode.
if (process.env.ENVIRONMENT == "dev") {
app.use(
cors({
origin: "*",
helmet({
crossOriginResourcePolicy: {
policy: process.env.ENVIRONMENT == "dev" ? "cross-origin" : "same-origin",
},
})
);
}
// Apply rate limiting
const postLimiter = rateLimit({