Skip to content

Next.js CDN (App-router) withSentryConfig in Dev mode broke client side routing #8727

@thasuohm

Description

@thasuohm

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

7.61.0

Framework Version

Next 13.4.10

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. set up HOST (my setting is 127.0.0.1 cdn.localhost)

  2. config next.config.js

async headers() {
    return [
      {
        source: '/_next/:path*',
        headers: [
          {
            key: 'Access-Control-Allow-Origin',
            value: '*',
          },
        ],
      },
    ]
  },
assetPrefix: 'http://cdn.localhost:3000',
crossOrigin: 'anonymous',

module.exports = withSentryConfig(nextConfig)

  1. run dev mode pnpm dev
  2. client-side route to some page

Expected Result

no CORS error happen and the route correctly without a full reload

Actual Result

  1. I am in route /a
  2. I click Link tag to go to /b
  3. It got an error CORS and the current page has a full reload and i am still in /a
  4. click Link tag to go to /b
  5. error disappears and go to /b correctly
Screenshot 2566-08-03 at 16 58 43

this happens only when I set assetPrefix + withSentryConfig and run in dev mode

Metadata

Metadata

Assignees

Labels

Package: nextjsIssues related to the Sentry Nextjs SDK

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions