Node.js saves the hash of the url after response.redirect

I have seen many JavaScript fixes for this using window.location, but nothing for Node.js.

I use OAuth to connect users to Facebook. After logging in, Facebook redirects your callback URL and appends "# =" to it. The problem in my callback route is being redirected to another URL, but the URL fragment (hash) is carried over.

This is my Facebook callback route:

exports.facebook_signin_complete = function(req, res)
{
    res.redirect('/profile');
};

If I remove the redirect, the URL will be /auth/facebook/callback#_=_, and if I save the redirect, it will /profile#_=_. Why is the hash carried over? This is a page anchor marker, so I would be very surprised if this is what it should have done.

+4
source share
1 answer

The hash in the URL is only on the client side, so you cannot change it on the server side. When I ran into the same problem , I just added the window.location.hash = '';JS to the top of my source file.

+2
source

Source: https://habr.com/ru/post/1545305/


All Articles