manchenkoff / nuxt-auth-sanctum

Nuxt module for Laravel Sanctum authentication
https://manchenkoff.gitbook.io/nuxt-auth-sanctum/
MIT License
116 stars 16 forks source link

fix: use updated csrf token on first login #117

Closed manchenkoff closed 2 days ago

manchenkoff commented 3 days ago

Is your PR related to a specific issue/feature? Please describe and mention issues.

Closes #108 and probably related #6 (comments from @alecritson).

Due to the Nuxt hack with the runWithContext call for request/response interceptors, there was an edge case when cookies after refresh were not included in the result headers due to missing await keyword, thus CSRF token was missing or was used from the previous API response.

Additional context

This PR changes how the Nuxt instance will be passed to each interceptor. Now each interceptor is wrapped with the current instance context instead of running a loop with one instance.

Checklist: