Skip to content

Rewrites broken with TypeError: Invalid URL in current canary #75956

@lforst

Description

@lforst

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/cranky-raman-6q3rg2

To Reproduce

  1. Start the repro app in dev or prod mode
  2. Click button on page
  3. Observe internal server error in nextjs

Current vs. Expected behavior

I expect the request to go through but instead it causes an internal server error.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4242
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.2.0-canary.54 // Latest available version is detected (15.2.0-canary.54).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Redirects

Which stage(s) are affected? (Select all that apply)

next start (local)

Additional context

We are making use of the specific rewrite in the Sentry Next.js SDK and it breaks prod users on canary right now.

I bisected the issue to be introduced by #74776 and tried to figure out why it breaks but couldn't figure out why exactly.

This is the rewrite that breaks:

  async rewrites() {
    return [
      {
        source: `/monitoring(/?)`,
        has: [
          {
            type: "query",
            key: "o",
            value: "(?<orgid>\\d*)",
          },
          {
            type: "query",
            key: "p",
            value: "(?<projectid>\\d*)",
          },
        ],
        destination:
          "https://o:orgid.ingest.sentry.io/api/:projectid/envelope/?hsts=0",
      },
    ];
  },

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions