Skip to content

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

Closed

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",
      },
    ];
  },

Activity

  1. added
    Redirects
    on Feb 12, 2025
  2. self-assigned this
    on Feb 12, 2025
  3. steve-marmalade commented on Feb 13, 2025

    @steve-marmalade

    I am also seeing an issue with rewrites in canary, but it only shows up when deployed on Vercel and I don't see any error messages (the behavior I'm seeing is that the URL bar updates correctly but the page never navigates). @wyattjoh is this related or should I open a separate issue?

  4. lforst commented on Feb 13, 2025

    @lforst
    ContributorAuthor

    @steve-marmalade I think what would help is if you shared the rewrite and maybe also (if present) the stalling/failing request from the network tab.

  5. steve-marmalade commented on Feb 13, 2025

    @steve-marmalade

    Here are two rewrites that aren't working (note that both of them use a :pattern, which seems relevant based on the fix in #75973)

      async rewrites() {
        return [
          {
            source: "/q/:path",
            destination: "/q/:path/all",
          },
          {
            source: "/u/:userName",
            destination: "/u/:userName/a",
          },
        ];
      },

    I don't see any hanging or failing network requests.

  6. github-actions commented on Feb 28, 2025

    @github-actions
    Contributor

    This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

  7. locked as resolved and limited conversation to collaborators on Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Redirectslocked

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions