You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
This is the result from Postman after sending the POST request to the /login endpoint (Exactly the one I'm expecting)
When I check the flask's server logs after the request with Postman, this is what I see:
As you can see, as I successfully provided the user credentials to the /login endpoint, I was redirected to the route /. However, when I attempt to do the same from my VueJS frontend using axios, although I'm successfully redirected to the / route, a second redirect occurs, sending me back to the /login route, as you can check in the logs:
First, I thought that maybe the form being send by axios didn't have the right format, but I checked, the form sent by Postman and the one sent by axios look exactly the same. (the first log is the form received by Flask's server from postman and the second one the form received from axios/vue):
I also considered that maybe, for some reason, Vue wasn't allowing the redirect, so I added two new endpoints to my backend just for testing the redirect:
I changed the axios request URL to /redirect and I was successfully redirected. So obviously this is not a problem from Vue/Axios side, but from Flask side.
Why this isn't working?
The text was updated successfully, but these errors were encountered:
My guess is the second redirect is occuring due to @login_required - i.e. - although you successfully logged in - when the redirect happens to "/" it doesn't think you are logged in.
This could be because axios isn't sending the session cookie - I don't know why that would be. Try opening up dev tools in your browser where you are using axios and look for the response cookie from /login and make sure it is getting sent...
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When I try to login a user from VueJS/Axios (against the
/login
route from Flask-Security), Flask fails to redirect me once the login succeeds.I removed
WTF_CSRF
to make the login only dependent on the user's email and password. Here my config:Then, I tested the endpoint using Postman to make sure I was able to login properly against the
/login
endpoint, and it works just as expected.This is the endpoint I'm expecting to redirect to after successfully login in...
This is the result from Postman after sending the POST request to the
/login
endpoint (Exactly the one I'm expecting)When I check the flask's server logs after the request with Postman, this is what I see:
As you can see, as I successfully provided the user credentials to the
/login
endpoint, I was redirected to the route/
. However, when I attempt to do the same from my VueJS frontend using axios, although I'm successfully redirected to the/
route, a second redirect occurs, sending me back to the/login
route, as you can check in the logs:This is how my axios' call from Vue looks like:
First, I thought that maybe the form being send by axios didn't have the right format, but I checked, the form sent by Postman and the one sent by axios look exactly the same. (the first log is the form received by Flask's server from postman and the second one the form received from axios/vue):
I also considered that maybe, for some reason, Vue wasn't allowing the redirect, so I added two new endpoints to my backend just for testing the redirect:
I changed the axios request URL to
/redirect
and I was successfully redirected. So obviously this is not a problem from Vue/Axios side, but from Flask side.Why this isn't working?
The text was updated successfully, but these errors were encountered: