vercel / vercel/next.js

Redirect fails when destination URL includes a hash with query parameters

Open
#81,124 3 comments 0 reactions 1 assignee View on GitHub

@icyJoseph is already working on this.

Since Jul 1, 2025.

Redirects
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/sharp-easley-8lwyxd?workspaceId=ws_HLf3J1mV3xt1bAoXr33ThK

To Reproduce
  1. Add a redirect in next.config.ts where destination includes a hash like https://www.example.com/#/login?return=something, as in redirecting to an application using hash based routing, and the hash includes query params
  2. When triggering the redirect, Next fails with [TypeError: Unexpected MODIFIER at 8, expected END]
Current vs. Expected behavior

Redirect should not fail with ? in a hash

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): 4102
  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.4.0-canary.104 // Latest available version is detected (15.4.0-canary.104).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.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 dev (local)

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.