Discussion on: PKCE authenticaton for Nuxt SPA with Laravel as backend

devondahon profile image

Why not using @nuxtjs/auth-next module ?

If it's not flexible enough, you can make your own scheme like this:

import Oauth2Scheme from '@nuxtjs/auth-next/dist/schemes/oauth2'

export default class LaravelPassport extends Oauth2Scheme {
  async logout() {
    if (this.options.endpoints.logout) {
      await this.$auth
        .requestWith(this.name, this.options.endpoints.logout)
        .catch(() => {})
    return this.$auth.reset()

And then use it like this in nuxt.config.js:

  auth: {
    redirect: {
      logout: '/',
      callback: '/auth/callback'
    strategies: {
      laravelPassport: {
        provider: 'laravel/passport',
        scheme: '~/schemes/laravelPassport',
        url: 'http://backend.test',
        endpoints: {
          userInfo: '/api/user',
          logout: {
            url: '/api/logout',
            method: 'post'
        clientId: '4',
        clientSecret: '***'
stefant123 profile image
StefanT123 Author

What you did here is almost the same as if you have done it custom, without using the nuxtjs/auth-next module. So why should we introduce another package in our project if the code is similar?!