# Routing not working in Vercel

**URL:** <https://forum.codewithmosh.com/t/routing-not-working-in-vercel/21939>\
**Category:** React\
**Created:** [August 8, 2023, 7:05pm UTC](https://forum.codewithmosh.com/t/routing-not-working-in-vercel/21939 "2023-08-08T19:05:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SubuHunter](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/subuhunter/32/5722_2.png) [@SubuHunter](https://forum.codewithmosh.com/u/SubuHunter)\
**Post date:** [August 8, 2023, 7:05pm UTC](https://forum.codewithmosh.com/t/routing-not-working-in-vercel/21939/1 "2023-08-08T19:05:41Z")

</div>

I recently created a landing page after finishing Mosh’s latest React 18 course.

I deployed it in Vercel, Everything seemed to work fine. I added a new page today by installing the react-router and everything seemed to work great in my local env.

But When I deployed it in Vercel and checked the new page, I’m getting a 404 error. Not sure what I’m doing wrong.

This is the router file’s code

```auto
import { createBrowserRouter } from "react-router-dom";
import App from "../App";
import ThankYou from "../ThankYou";

const router = createBrowserRouter([
    { path: '/', element: <App />},
    { path: '/thankyou', element: <ThankYou />}
])

export default router;

```

This is from my vercel link

 ![image](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/6/61216abdad8d36320ad990bec7dc964ccbb5d49e.png)

This is the home page - [https://studyabroad.mugdhasmastersconsultancy.com/](https://studyabroad.mugdhasmastersconsultancy.com/)

And this is the new page i created recently - [https://studyabroad.mugdhasmastersconsultancy.com/thankyou](https://studyabroad.mugdhasmastersconsultancy.com/thankyou)

---

<div class="post-metadata">

**Author:** ![SubuHunter](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/subuhunter/32/5722_2.png) [@SubuHunter](https://forum.codewithmosh.com/u/SubuHunter)\
**Post date:** [August 9, 2023, 7:37pm UTC](https://forum.codewithmosh.com/t/routing-not-working-in-vercel/21939/2 "2023-08-09T19:37:51Z")

</div>

Found the solution for this issue,

Thanks to this guy’s comment in stack overflow - [reactjs - Vite.js React Build Not Redirecting On Netlify And Vercel - Stack Overflow](https://stackoverflow.com/questions/66667636/vite-js-react-build-not-redirecting-on-netlify-and-vercel/66686684#66686684:~:text=This%20is%20not,the%20project%20called)

Created a file called “vercel.json” in the root directory of the project

And added this code

```auto
{
    "rewrites": [{ "source": "/(.*)", "destination": "/" }]
}

```

Voila 🕶
