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

145
Views
cómo hacer que el enrutador acceda por token

Tengo token por back-end

 axios.post(process.env.VUE_APP_LOGIN, payload) .then(response => { const {access_token, token_type, user} = response.data; this.token = access_token this.$store.commit('auth/set_Token', access_token) this.store.commit('auth/set_User', user) this.$store.commit('auth/set_TokenType', token_type) axios.defaults.headers.post['Authorization'] = `Bearer ${access_token}`

y quiero hacer enrutadores públicos y autenticados. pero no puedo entender cómo verificar y hacer el encabezado [ authenticated ]

 Vue.use(VueRouter) const routes = [ { name: 'DataBase', path: '/table', component: Table, }, { name: 'Home', path: '/', component: Main, }, { name: 'Login', path: '/login', component: Login, meta: { public: true, hideHeader: true, hideFooter: true, }, }, { name: 'Dictionary', path: '/dovid', component: Dovid, meta: { } }, ] const router = new VueRouter({ mode: 'history', base: process.env.BASE_URL, routes })

¿Necesito usar el enrutador antes de cada uno? ¿o que? tal vez tengas algunos buenos documentos. Estaré muy agradecido.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar "router.beforeEach" para eso. Aquí hay un ejemplo

 router.beforeEach((to, from, next) => { // if route is not auth-protected, or user is logged if (to.matched.some(matchAuthProtectedRoute) && !isLogged()) { next({ path: '/login', query: { back: to.fullPath } }); return; } next(); });
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!