Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
katarzynakleczar opened this issue Dec 13, 2021 · 0 comments
Closed
4 tasks done
Labels

Comments

@katarzynakleczar
Copy link

katarzynakleczar commented Dec 13, 2021

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
@nuxt-community nuxt-community locked and limited conversation to collaborators Jan 24, 2022
@bmulholland bmulholland converted this issue into discussion #1635 Jan 24, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

1 participant