Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

321
Visualizações
Nextjs custom 404 page not showing when accessing invalid url in netlify

I've created a 404.js file in /pages folder on my Nextjs project, the 404 page is working perfectly when entering an error or invalid URL in local but when its deployed in netlify they showing the default netlify error page.

enter image description here

version details

"next": "^10.0.4", 
"react": "17.0.2",

Tried netlify's redirect rule, but nothing happened

[[redirects]]
  from = "/*"
  to = "/404.html"
  status = 404
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I found a solution when randomly changed the redirects rule based on this article https://docs.netlify.com/routing/redirects/#syntax-for-the-netlify-configuration-file

Here is my fix, it's working when redeployed after.

Create a netlify.toml file in the project directory and paste below code.

[[redirects]]
  from = "/*"
  to = "/404"
  status = 404
about 4 years ago · Juan Pablo Isaza Relatório

0

I found two solution from this page => https://www.netlify.com/blog/2019/01/16/redirect-rules-for-all-how-to-configure-redirects-for-your-static-site/

  1. I added a _redirects file inside the /public folder like /public/_redirects. I then pasted /* /index.html 200 into the _redirects file.

redeploy your app and it's done

Or second way:

  1. Add netlify.toml file to the root directory of your project and paste in to:

    [[redirects]]
       from = "/*"
       to = "/"
       status = 200
    

redeploy your app and it's done

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda