Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
Getting 404 on a routed page with Vite and React Router v6

I am having a little issue with routing, my routing is working as intended however there is a slight quirk I can't figure out.

I have two routes:

  • domain.com
  • domain.com/logs

On domain.com I have the following header.

<nav className="space-x-4">
          <Link to="/">
            <LinkButton btnText="Home" />
          </Link>
          <Link to="/logs">
            <LinkButton btnText="Logs" />
          </Link>
</nav>

Clicking through on these links works fine as expected. However when I am on domain.com/logs and refresh the page i get a 404. Below is how I have set up my routing.

import Logs from './routes/Logs'

const root = ReactDOM.createRoot(document.getElementById('root'))
root.render(
  <BrowserRouter>
    <Routes>
      <Route path="/" element={<App />} />
      <Route path="/logs" element={<Logs />} />
    </Routes>
  </BrowserRouter>
)

I have come across this link: https://vercel.com/docs/concepts/edge-network/frequently-asked-questions#why-do-i-see-a-404-error-when-accessing-my-deployment

I am building from the whole dir so should include the routes folder.

Now I am not sure if this is something to do with Vercel or Vite. Any suggestions would be great. Also to note this...works perfectly locally so must be a build thing.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The index.html that serves up your website when you visit domain.com also needs to be served up when you visit domain.com/logs your client side routing will then work.

The react-router will then show your app in its correct state.

More info can be found here describing deployments with client side routing https://create-react-app.dev/docs/deployment/#serving-apps-with-client-side-routing

im not familiar with vercel but they will probably have a wildcard option to serve the index document up for any unresolved routes.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda