From 239cd14521e4724762984c9b8e1d32fb7ea85fce Mon Sep 17 00:00:00 2001 From: dimitar Date: Tue, 1 Apr 2025 03:56:32 +0200 Subject: [PATCH] posthog again --- backend/src/app.module.ts | 5 ++++- backend/src/config/cors.config.ts | 5 +++++ backend/src/main.ts | 8 ++++++++ frontend/vite.config.js | 30 ++++++++---------------------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index a65aa94..30456a3 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -57,7 +57,9 @@ export class AppModule implements NestModule { const allowedOrigins = [ "http://localhost:5173", "http://localhost:4173", - "https://eu.i.posthog.com/e/?retry_count=1&ip=1&_=1743469741081&ver=1.234.4&beacon=1", + "https://eu.i.posthog.com", + "https://app.posthog.com", + "https://eu.posthog.com", "https://www.placebo.mk", "https://placebo.mk", "https://imkapi.oblak.solutions", @@ -81,6 +83,7 @@ export class AppModule implements NestModule { ); res.header("Access-Control-Max-Age", "86400"); res.status(204).end(); + return; } diff --git a/backend/src/config/cors.config.ts b/backend/src/config/cors.config.ts index 2e5caf8..f25c638 100644 --- a/backend/src/config/cors.config.ts +++ b/backend/src/config/cors.config.ts @@ -4,6 +4,9 @@ export const corsConfig = { "https://www.placebo.mk", "https://placebo.mk", "https://imkapi.oblak.solutions", + "https://eu-assets.i.posthog.com", + "https://app.posthog.com", + "https://eu.posthog.com", ], methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"], credentials: true, @@ -13,5 +16,7 @@ export const corsConfig = { "Content-Type", "Accept", "Authorization", + "posthog-session-id", + "ph-session-id", ], }; diff --git a/backend/src/main.ts b/backend/src/main.ts index 07611fd..042d3a8 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -36,15 +36,23 @@ async function bootstrap() { "'unsafe-inline'", "'unsafe-eval'", "https://eu-assets.i.posthog.com", + "https://app.posthog.com", + "https://eu.posthog.com", ], connectSrc: [ "'self'", "https://eu.posthog.com", "https://eu-assets.i.posthog.com", + "https://app.posthog.com", ], imgSrc: ["'self'", "data:", "https:"], styleSrc: ["'self'", "'unsafe-inline'"], fontSrc: ["'self'", "data:", "https:"], + rameSrc: [ + "'self'", + "https://eu-assets.i.posthog.com", + "https://app.posthog.com", + ], }, }, crossOriginResourcePolicy: { diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 96b2e03..f50c8af 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -4,28 +4,14 @@ import react from "@vitejs/plugin-react"; export default defineConfig({ plugins: [react()], server: { - proxy: { - "/api": { - target: "https://imkapi.oblak.solutions", - changeOrigin: true, - secure: false, - ws: true, - configure: (proxy, _options) => { - proxy.on("error", (err, _req, _res) => { - console.log("proxy error", err); - }); - proxy.on("proxyReq", (proxyReq, req, _res) => { - console.log("Sending Request to the Target:", req.method, req.url); - }); - proxy.on("proxyRes", (proxyRes, req, _res) => { - console.log( - "Received Response from the Target:", - proxyRes.statusCode, - req.url, - ); - }); - }, - }, + port: 5173, + cors: { + origin: [ + "https://eu-assets.i.posthog.com", + "https://app.posthog.com", + "https://eu.posthog.com", + ], + allowedHeaders: ["posthog-session-id", "ph-session-id"], }, }, });