nextjs - 💡(How to fix) Fix basePath and rewrites work locally but not on Vercel [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#89505Fetched 2026-04-08 02:02:47
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
0
Timeline (top)
labeled ×5closed ×1commented ×1issue_type_added ×1

Code Example

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 7988
  Available CPU cores: 8
Binaries:
  Node: 24.12.0
  npm: 11.1.0
  Yarn: 1.22.22
  pnpm: 10.8.1
Relevant Packages:
  next: 16.1.6 // Latest available version is detected (16.1.6).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/Ammar52501/test-rewrite

To Reproduce

  1. Clone the following repository: https://github.com/Ammar52501/test-rewrite

  2. Install dependencies and run the project locally:

    • bun install
    • bun run dev or bun run build && bun run start
  3. Verify that basePath and rewrites work correctly in local environment

  4. Deploy the same repository to Vercel

  5. Access the deployed app and observe that the rewrite no longer works

Current vs. Expected behavior

  • The deployed app on Vercel should behave the same as local development
  • basePath and rewrites() should work consistently in all environments

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 7988
  Available CPU cores: 8
Binaries:
  Node: 24.12.0
  npm: 11.1.0
  Yarn: 1.22.22
  pnpm: 10.8.1
Relevant Packages:
  next: 16.1.6 // Latest available version is detected (16.1.6).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Connection, Redirects, Pages Router, Not Found

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

Vercel (Deployed)

Additional context

No response

extent analysis

TL;DR

  • The issue with basePath and rewrites not working on Vercel deployment can likely be resolved by configuring Vercel to handle rewrites correctly.

Guidance

  • Review Vercel configuration to ensure it supports Next.js rewrites and basePath settings.
  • Check the vercel.json file for any missing or incorrect settings related to rewrites.
  • Verify that the next.config.js file is correctly configured for Vercel deployment, including any necessary settings for basePath and rewrites.
  • Test the deployment with a minimal vercel.json configuration to isolate the issue.

Example

No code snippet is provided as the issue lacks specific details about the configuration files.

Notes

The solution may depend on the specific versions of Next.js and Vercel being used, as well as the exact configuration of the next.config.js and vercel.json files.

Recommendation

  • Apply workaround: Configure Vercel to handle Next.js rewrites and basePath settings correctly, as the issue seems to be related to the deployment configuration rather than the code itself.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix basePath and rewrites work locally but not on Vercel [1 comments, 2 participants]