Skip to content

Make @sentry/nextjs tunnel work via next.confg.js.rewrites #5571

@wscourge

Description

@wscourge

Problem Statement

When AdBlocker ULTIMATE (Firefox) is enabled, I get the following error client-side:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://oXXXXXX.ingest.sentry.io/api/XXXXXXXX/envelope/?sentry_key=XXX&sentry_version=7. (Reason: CORS request did not succeed). Status code: (null).

image

Solution Brainstorm

I believe that the workaround for this would be to use NextJS rewrites in the next.conifg.js file:

const { withSentryConfig } = require("@sentry/nextjs")

const sentryWebpackPluginOptions = { ... }
module.exports = withSentryConfig(sentryWebpackPluginOptions, {
  ...
  rewrites: async function() {
    return [
       {
         source: "/sentry/:path*",
         // https://abcdefghijklmnopqrstquwxyzabcdef@o123456.ingest.sentry.io/1234567
         destination: `https://${process.env.SENTRY_DSN.split("@")[1].split("/")[0]}/:path*`,
       },    
    ]
  }
  ...
}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions