From 741f92b7c23c1e63854086b85f20998943bad7e5 Mon Sep 17 00:00:00 2001 From: Simon Heider Date: Mon, 26 Aug 2024 15:18:41 +0200 Subject: [PATCH] set cors options to try with posthog (credetntials) --- app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 1650447..c5fe8f3 100644 --- a/app.js +++ b/app.js @@ -14,7 +14,13 @@ const posthog = new PostHog( var todosRouter = require('./routes/todos'); var app = express(); -app.use(cors()); +const corsOptions = { + origin: '*', // Allow requests only from your frontend's origin + methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], // Allow these HTTP methods + allowedHeaders: ['Content-Type', 'Authorization'], // Allow these headers + credentials: true // Allow credentials if you are using them (e.g., cookies, authentication) +}; +app.use(cors(corsOptions)); // view engine setup app.set('views', path.join(__dirname, 'views'));