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

302
Visualizações
How to get the error (404) page into the ''dist" directory in nuxt?

I created an error page as in the documentation and it works.

https://nuxtjs.org/docs/2.x/concepts/views#error-page

In short, I create an error.vue file in the /layouts directory and optionally pass it a custom layout.

<template>
  <div>
    <h1 v-if="error.statusCode === 404">Page not found</h1>
    <h1 v-else>An error occurred</h1>
    <NuxtLink to="/">Home page</NuxtLink>
  </div>
</template>

<script>
  export default {
    props: ['error'],
    layout: 'error' // custom layout
  }
</script>

But my product task requires the 404 page to go into the /dist directory after the generate command.

Like this

dist/
--| 200.html
--| 404.html //do not exist for me

The following solutions didn't help:

  1. If I just add a 404 page to the /pages directory, then Nuxt will still show its default error page.

Is there a laconic way to do this? Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I managed to solve my problem by adding this code to nuxt.config.js.

router: {
  extendRoutes(routes, resolve) {
    routes.push({
      name: 'custom',
      path: '*',
      component: resolve('@/pages/404.vue')
    })
  }
},

Now 404.vue is in the /pages directory, and the 404.html page is in the /dist directory.

Documentation: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-router#extendroutes

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