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

135
Visualizações
Nuxt - Handle routes at runtime with ssr activated

Hello there: quick question I've

  • a Nuxt app with the target: 'server' in the nuxt.config.js
  • an API with an endpoint that give me, for a given path, a template associated ( eg: /person/maxime will give me template: PersonsSingle )
  • a vue component that handles this page ( eg: _pages/person.vue )

How can I handle this at runtime ? I guess it's something to do with the middlewares but which one and what is the best strategy here ?

PS: I use this system because two urls with the same structure (eg: /person/maxime and /person/sam could lead to two completely different templates ). Don't ask why I have to deal with it :/

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

0

This is how I would do it.

async asyncData({ $axios }) {
  const data = await $axios.$get('...')

  const templateType = data.templateType

  return {
    templateType
  }
}
<template>
  <div>
    <page-1 v-if="templateType === 'foo'" />

    <page-2 v-else />
  </div>
</template>
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