Skip to content

Fix Vercel SPA routing with rewrite config#29

Closed
MelonChicken wants to merge 1 commit into
Driedoutjerky:mainfrom
MelonChicken:main
Closed

Fix Vercel SPA routing with rewrite config#29
MelonChicken wants to merge 1 commit into
Driedoutjerky:mainfrom
MelonChicken:main

Conversation

@MelonChicken

Copy link
Copy Markdown
Collaborator

Summary

  • Added vercel.json to support client-side routing on Vercel.
  • Redirects all routes to index.html so React Router can handle page navigation.

Why

When users directly access or refresh routes like /shop, /login, or /archive, Vercel tries to find those paths as real server files and returns 404 NOT_FOUND.

This rewrite ensures that Vercel serves the frontend app first, and then React Router handles the route internally.

Changes

  • Added vercel.json
  • Configured rewrite rule:
{
  "rewrites": [
    {
      "source": "/(.*)",
      "destination": "/index.html"
    }
  ]
}

How to Test

  1. Open the deployed site. (https://memory-egg-front.vercel.app/)
  2. Navigate to pages such as /shop, /login, or /archive.
  3. Refresh the page directly on those routes.
  4. Confirm that the page loads without 404 NOT_FOUND.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant