From fce084f5907a173a9c05fca9b9ed7d5a1b8e6d26 Mon Sep 17 00:00:00 2001 From: Maxime Cannoodt Date: Thu, 30 Jun 2022 09:28:49 +0200 Subject: [PATCH] fix cors with helmet --- server/prisma/dev.db | Bin 815104 -> 815104 bytes server/server.ts | 17 +++++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/server/prisma/dev.db b/server/prisma/dev.db index 88220eab946516f816e3f5da3f221f33c1f2672e..2ec2951957b213cba8514274e8541fd15ddf0858 100644 GIT binary patch delta 2409 zcmZ{l%a0pL9mi)fj5mq%+5;zcrEox-tdn(BcUN`Qgc{cc+b z&m@OE@e)G$58$x5z$%PDXeGoU9FRal>+aU) zTi@TWjz5COAHi>Z;p+Q)dwWk*T~hVv+qca9_kVEj``g2J)$QX4SB~Gga=fqVf~o^m zpF6#BeE5%FUA%t%vHHW_j~-qr1zx#u{qaLk3fzDARw)oT{b4C^aQ#q;Kfe9&CvOL` z2X`+2_TfwS0+}1ZcY|LKj)Uc(9{l{}zpK^Ky}&n4|9UU*r%T&c58mA8E&^WHK?9(E z4p|xliiwoI`NlI<428c_`-7#iLgU`XADMTbsn%@j?o>2h8V-XS-I($_XX>b@?^JiS zG)9~G2oir8`k%T59_{tjhYfS0KJ2Y##$@Kv*PlIXdOiU_$2+x8XG__$?b~N6_BQ}% z^uN#AqGuA0Zaq`+d@=+8lASu9G1+&heC?@fZ2elWOv_v34a z!P4IK8`o}L1y|k*mfm~$=9h!pli?c|-#k3LfA!?*|21s?b2PbuBp) zsm7oMX{aGdn^!GRPevl66v8}dxE?q9eP_yh(F9Jnw6a$oVi{ZInk~O5{FLc0teHQ< zete}J=_S7Hbl0*x;>b$#)tDE&9?n$bW43~g-e7XXJZs$#_lv7cDJ$2xb$cPSOm=Ym2nK&8VJqN6I>O~LG^l5Sc{QcorqQD1hCx=A_9 zMnfGric>v2o6<(L%~~m8uy8k1sMK6E*y2dKpljYyZ&*szK$kRIM{ZSkGRY{1ZmxwR zF2fR2Vg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,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: "*", - }) - ); -} +app.use( + helmet({ + crossOriginResourcePolicy: { + policy: process.env.ENVIRONMENT == "dev" ? "cross-origin" : "same-origin", + }, + }) +); // Apply rate limiting const postLimiter = rateLimit({