Skip to content

Laravel Passport provider with password grant create request with strage and incorrect url #1360

@katarzynakleczar

Description

@katarzynakleczar

Version

module: 5.0.0-1637745161.ea53f98
nuxt: 2.15.8

Nuxt configuration

mode:

  • spa

Nuxt configuration

const apiUrl = process.env.API_PROTOCOL + process.env.API_HOST
[...]
 // Auth module configuration: https://auth.nuxtjs.org/guide/scheme
  auth: {
    strategies: {
      // Laravel Pasport Scheme: https://auth.nuxtjs.org/providers/laravel-passport
      laravelPassport: {
        provider: 'laravel/passport',
        // scheme: 'oauth2',
        endpoints: {
          authorization: apiUrl + '/oauth/token',
          token: apiUrl + '/oauth/token',
          userInfo: apiUrl + '/user',
        },
        grantType: 'password',
        url: apiUrl,
        clientId: process.env.PASSPORT_CLIENT_ID,
        clientSecret: process.env.PASSPORT_CLIENT_SECRET,
      },
    },
  },
[...]

.env

API_PROTOCOL=http://
API_HOST=api.app-name.loc
API_PREFIX=/1.0/api
API_PORT=80
PASSPORT_CLIENT_ID=2
PASSPORT_CLIENT_SECRET=secret

Reproduction

https://codesandbox.io/s/nuxt-auth-error-4wkfb?file=/nuxt.config.js

What is expected?

When grantType isn't set request url host is the same as it url option (ex. http://api.app-name.loc/ ).
image
(caption: app-name.loc host does't exist, it is only exapmle to show, that it work correctly)

It is expected that set grantType option to password not change this behavior.

What is actually happening?

After set grantType, url and endpoints.token options are ignored and request url is http://localhost:3000/_auth/{strategyName}/token. In this exapmple stategy name is laravelPassport Proxy settings in axios module are ignered, create proxy _auth/{strategyName} doesn't work. Nuxt cannot connect to laravel api.
image

Steps to reproduce

Create new nuxt project with auth module, copy Laravel Pasport provider settings from module docs and set "grantType" option to "password" or click in link above where it's configured ("Login" button in this app create new auth request with bug).

Additional information

Checklist

  • I have tested with the latest Nuxt version and the issue still occurs - yes
  • I have tested with the latest module version and the issue still occurs - yes
  • I have searched the issue tracker and this issue hasn't been reported yet - similar issue Endpoint axios calls can't be extended #1289 but there is no answer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions