Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!