Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

332
Vistas
How to implement Nuxt Server Middleware Google authorization?

I've got the following auth configuration in my nuxt.config.js

auth: {
  strategies: {
    google: {
      client_id: process.env.GOOGLE_KEY,
      codeChallengeMethod: '',
      scope: ['profile', 'email'],
      responseType: 'token id_token'
    }
  },
  redirect: {
    login: '/login',
    logout: '/logout',
    home: '/',
    callback: '/welcome'
  },
  rewriteRedirects: false
},
router: {
  middleware: ['auth']
},
serverMiddleware: [
  { path: '/db', handler: '~/api/db.js' },
],

This setups frontend authentication, so all my .vue pages are protected. Besides that, I've got some serverMiddleware, like in my api/db.js

const app = require('express')()

app.get('/fields/:schema', async (req, res) => {
  var result = []
  // some logics here
  return result;
})

Request to this resource is not protected by any auth, but I've noticed in Network tab in browser, that all request made by $axios.$get('db/fields/some_schema') from my .vue pages set some Google cookie, like

auth.strategy=google; auth._token.google=Bearer...

which is not used in my serverMiddleware api/db.js

Does Nuxt.js has some out of box way to setup Google authentication for server middleware? What is the right way to setup it?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I had to use this nuxt config

  auth: {
 strategies: {
   google: {
    clientId: 'to be added',
    clientId: '<your cliendID here>',
    codeChallengeMethod: '',
    responseType: 'code',
    endpoints: {
      token: 'http://localhost:8000/social-login/google/',
      userInfo: 'http://localhost:8000/auth/user/'
    },
   },
 }
},

and implement backend token and userInfo endpoints

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda