DEV Community

Discussion on: Secure authentication in Nuxt SPA with Laravel as back-end

Collapse
 
mkantautas profile image
Mantas Kantautas

Yeah, this is clear, but for some reason, the cookie is not being passed from nuxt in the first place in the await this.$axios.$post('refresh-token'); . Can this be because my front-end and back-end are on different domains? And how to overcome this?

Thread Thread
 
mkantautas profile image
Mantas Kantautas • Edited

dump(request()->cookie()) returns an empty array on Cors.php middleware on /api/refresh-token request

Thread Thread
 
mkantautas profile image
Mantas Kantautas

Will your guide work in case my laravel api is site.test and my nuxt is running on localhost:3000 for e.g.? Because I coming to the conclusion that top-level domains must be the same for this to work?

Thread Thread
 
stefant123 profile image
StefanT123

No, your apps can be on different domains, and this would still work. I can't know for sure what went wrong in your case. Maybe the httponly cookie isn't set in the first place, or you're sending the request without the cookie. Until I see the errors or some code, I can't know what's wrong.

Thread Thread
 
brainuso profile image
brainuso • Edited

Was there a solution to this issue? I'm currently having the exact error when refresh token is called.

Update:
I ran this in the login after grantPasswordToken function:

Log::notice(cookie('refresh_token'));

and here is the response:

refresh_token=deleted; expires=Mon, 28-Oct-2019 22:11:22 GMT; Max-Age=0; path=/; httponly