Skip to content Skip to sidebar Skip to footer

My Express.js And Passport.js Middleware Are All Working And Are Being Called, But The Page Does Not Redirect

I am currently developing a node/express server, and I decided to use passport-local for user authentication along with a local MongoDB server. I am using a POST method from an htm

Solution 1:

An Ajax call from the Javascript in a web page does not automatically redirect based on the http response. Things that redirect automatically are things where the call to the server is not directly from Javascript such as clicking on a link, submitting a form (without Javascript), typing an URL into the URL bar, etc...

Instead when a request is sent from Javascript (as yours appear to be), the Javascript gets the response back and that response is available to your Javascript. If you see it's a 302 and you want to redirect, then you get the location header and set window.location to that redirect URL to cause the page to redirect.

Post a Comment for "My Express.js And Passport.js Middleware Are All Working And Are Being Called, But The Page Does Not Redirect"