Friday, 16 April 2021

NuxtJs Auth with multiple strategies, endpoints getting overwritten

I am building a web app using NuxtJs and I am using nuxtjs/auth-next for OAuth authorization with Google and Facebook auth providers. I have configured post authorization endpoints to fetch token from backend, while it works when I just have one Strategy in nuxt config (either google or facebook), but when I have both then both logins are using the first strategy's endpoint. I have spent a lot of time on this, please share if you have any thoughts on how to resolve this. Thanks!

Edit: This works fine on localhost, I don't see endpoints getting overwritten, but when deployed the first strategy's token endpoint gets applied to the second one as well

Here is my auth config in nuxt.config.js

  auth: {
    strategies: {
      facebook: {
        responseType: "code",
        endpoints: {
          token: Config.HOST + "/api/social-login/facebook/",
          userInfo: Config.HOST + "/api/auth/user/"
        },
        clientId: Config.FACEBOOK_CLIENT_ID,
        scope: ["public_profile", "email"],
        refreshToken: {
          property: "refresh_token",
          maxAge: 60 * 60 * 24 * 30
        }
      },
      google: {
        clientId: Config.GOOGLE_CLIENT_ID,
        responseType: "code",
        endpoints: {
          token: Config.HOST + "/api/social-login/google/",
          userInfo: Config.HOST + "/api/auth/user/"
        },
        codeChallengeMethod: "",
        refreshToken: {
          property: "refresh_token",
          maxAge: 60 * 60 * 24 * 30
        }
      }
    }
  }


from NuxtJs Auth with multiple strategies, endpoints getting overwritten

No comments:

Post a Comment