next.jskeycloaksentry

Request header field sentry-trace is not allowed by Access-Control-Allow-Headers in preflight response


I'm developing a Frontend using NextJS and Keycloak for auth-purpose. After adding Sentry, I'm facing this issue here, where the token endpoint of Keycloak is returning an error; So I can log in.

I've tried many things:

Now I don't have any more Idea, so I coming here for more help.


Solution

  • So after some investigations, I came across this tracingOrigins property that can be set using integrations like this:

    integrations: [
        new (Sentry.Integrations as any).BrowserTracing({
            tracingOrigins: [
                process.env.NEXT_PUBLIC_URL,
                process.env.NEXT_PUBLIC_BACKEND_URL,
                process.env.NEXT_PUBLIC_MATOMO_URL,
            ],
        }),
    ],
    

    This config is done inside the sentry.client.config.ts file. The downside is that, urls which are not included there, are simply not tracked.