From ef3b878e85308ef071881a3a5cad0dd4e12ea2f4 Mon Sep 17 00:00:00 2001 From: Stefan-5422 <32109571+Stefan-5422@users.noreply.github.com> Date: Tue, 7 Jun 2022 18:41:45 +0000 Subject: [PATCH] FIX: cors having stroke --- src/app.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app.ts b/src/app.ts index d41ffba..2491473 100644 --- a/src/app.ts +++ b/src/app.ts @@ -50,7 +50,7 @@ async function main() { logger.info("Using production mode"); // Configure cors - app.use( + /*app.use( cors({ origin: process.env.ALLOW_ORIGIN, allowedHeaders: ["Content-Type", "Authorization"], @@ -58,7 +58,13 @@ async function main() { methods: ["GET", "PUT", "PATCH", "POST", "DELETE"], optionsSuccessStatus: 204, }) - ); + );*/ + //Cors is for some reason broken on our server so set the Cors headers manually + app.use(function (req, res, next) { + res.header("Access-Control-Allow-Origin", "https://josport.at"); + res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); + next(); + }); } // Todo: Everything @@ -86,7 +92,7 @@ async function main() { app.use("/api/role-schemas", roleSchemaRouter); app.use("/api/media", mediaRouter); - + app.use("/api/users", userRouter); app.use("/api/teams", teamRouter);