-
Notifications
You must be signed in to change notification settings - Fork 910
Description
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/ ).

(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.

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