nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.93k stars 925 forks source link

Not set default data on endpoints config #1266

Open vUdav opened 3 years ago

vUdav commented 3 years ago

Version

module: 5.0.0-1624817847.21691f1 nuxt: 2.15.8

Nuxt configuration

mode:

Nuxt configuration

Before export default

const loginParams = new URLSearchParams()
loginParams.append('grant_type', 'password')
loginParams.append('client_id', '123')
loginParams.append('client_secret', '321')

const refreshParams = new URLSearchParams()
refreshParams.append('grant_type', 'refresh_token')
refreshParams.append('client_id', '123')
refreshParams.append('client_secret', '321')

export default {
auth: {
    strategies: {
      local: {
        scheme: 'refresh',
        token: {
          property: 'access_token',
          maxAge: 600, // 10 min
          global: true,
          // type: 'Bearer'
        },
        refreshToken: {
          property: 'refresh_token',
          data: 'refresh_token',
          maxAge: 60 * 60 * 24 * 30 * 365 // 1 year
        },
        endpoints: {
          login: {
            url: `${process.env.NUXT_ENV_BASE_URL_AUTH}/token`,
            method: 'post',
            data: loginParams,
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
            }
          },
          logout: false,
          refresh: {
            url: `${process.env.NUXT_ENV_BASE_URL_AUTH}/token`,
            method: 'post',
            data: refreshParams,
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded'
            }
          },
        }
      }
    }
  }

auth method on vue

const { email, password } = this

        try {
          const params = new URLSearchParams()
          params.append('username', email)
          params.append('password', password)

          const response = await this.$auth.loginWith('local', {
            data: params,
          })
          console.log(response)
        } catch (err) {
          console.log(err)
        }

What is expected?

Axios send data all params from endpoint config and from my auth method on vue.

What is actually happening?

Axios send params only from my auth method on vue.

Additional information

Checklist

vUdav commented 3 years ago

I'm write example: https://codesandbox.io/s/wonderful-grass-zoe82

Api request is must failed, but you can see on network sending datas. Sended only login and pass, not other datas from nuxt.config.js

bmulholland commented 2 years ago

We recently upgraded axios versions, so this issue may now be resolved. Please upgrade to latest auth-next and let me know if this is still happening.

vUdav commented 2 years ago

I'm update auth-next to 5.0.0-1643103966.eefc505, but problem not resolve.

Example: https://codesandbox.io/s/optimistic-fire-01v24