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

137
Visualizações
Nuxt router leads to wrong link after page reload

First, to demonstrate what I mean, I've set up a demo Nuxt blog at https://debadeepsen.com/nuxtblog/. It has the articles populated by the @nuxt/content package. The deployed website has been generated via the nuxt generate command and as such, is fully static. Now perform the following actions -

  • Go to the homepage and click on any of the links.
  • It takes you to the article you requested.
  • From the article page, you can click on any other link, which'll take you to a different article.

The steps taken above lead to results that are expected. But now, reload any of the article pages. You will notice the following -

  • A trailing slash (/) has been added to the URL in the address bar (I haven't tested on all browsers, but this appears to happen on at least Chromium-based ones).
  • The URLs for the links now have the current slug segment as part of the base URL, presumably due to the above occurrence. So for example, the second link now points to either https://debadeepsen.com/nuxtblog/what-is-settimeout/what-is-settimeout or https://debadeepsen.com/nuxtblog/vintage-photo-effect-with-css/what-is-settimeout (depending on which page you reloaded).

Obviously, these pages don't exist, and therefore the links are now broken.

My code is pretty straightforward. Here's the navigation menu -

<ul>
  <li v-for="article in list" :key="article.slug">
    <nuxt-link :to="article.slug">
      {{ article.title }}
    </nuxt-link>
  </li>
</ul>

The state variable list has correct data in it, no problem there.

In my nuxt.config.js, I have -

export default {
  // ...
  
  router: {
    base: '/nuxtblog/'
  },

  // ...
}

So, what am I doing wrong here and how can I fix this problem?

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

0

Either use named routes in your to property or start the path with a leading /.

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