I have a simple React + Vite project that I deployed on Vercel for the first time.
I’ve managed to fix the 404 error on refresh but some sub-domains aren’t rendering (e.g “/admin”).
I’m using react-router-v6 for the routing.
I have no idea how to configure my vercel.json.
that’s my code below:
const router=createBrowserRouter(
createRoutesFromElements(
<Route path='/' element={<Layout />}>
<Route path='' element={<Home />}/>
<Route path='products' element={<Catalogue />}>
<Route index element={<Product />}/>
<Route path='preview' element={<Preview />}/>
<Route path=':id' element={<Preview />}/>
</Route>
<Route path='cart' element={<Cart />}/>
<Route path='checkout' element={<ContactForm />}/>
<Route path='admin' element={<Admin />}>
<Route path='login' element={<Login />}/>
<Route path='dashboard' element={<Dashboard />}>
<Route path='' element={<Previews />}/>
<Route path='create' element={<Create />}/>
</Route>
</Route>
<Route path='*' element={<ErrorPage />}/>
</Route>
)
)
New contributor
Lemon Confidence is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.