Deploy SPA with react-router to Vercel

ruucm
Today I Solved
Published in
Jun 6, 2021

What

When you deploy your build files to the vercel server, sub-pages emit not found errors.

It means servers don’t know how to handle sub-pages (URLs) like yourdomain.com/my-page.

How

Make vercel.json file in your root directory, then add redirect rules like below.

{
"routes": [{ "src": "/[^.]+", "dest": "/", "status": 200 }]
}

That’s it!

References

--

--