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

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

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 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!