I have a simple React.js
application with wouter
-based routing and Vercel
deployments that drive me into a little issue where I have no idea about the solution. It always returns 404
after refresh (of subpage). It's worthly to notice my configuration of repository includes turbo
and few applications (server
and web
).
My code looks a bit like this.
<>
<Route path='/' component={Intro} />
<Route path='/dashboard' component={Dashboard} />
</>
Where on <Intro />
I have <Link />
to /dashboard
which should transfer me to <Dashboard />
page. And it does work on my local machine, in a container, and on Linux-based deployment, but it doesn't really work in vercel
deployment, even if I tried to resolve this issue with the configuration of repository/vercel.json
.
{
"github": {
"silent": true
},
"rewrites": [
{
"source": "(.*)",
"destination": "/index.html"
}
]
}
Also tried an alternative version of rewrites
and still the same issue.
{
"rewrites": [{ "source": "/(.*)", "destination": "/" }]
}
NOTE: I was also trying to use
react-router
but the same problem exists. Same problem exist when application is hosted onnetlify
but doesn't exist at all when hosted onheroku
or run insidedocker
container.
vercel
can have a problems with monorepo structure. Question you provided is on completely different topic. – Interknit