now the company has a project and a requirement that when logging in from an external URL, it will be automatically redirected to the home page, as follows:
http://localhost:8889/?sessionId=4724-3551655957868--736132069sh-sharp!/app/home
, then you need to take out the previously saved destination URL (such as the destination URL is the dashboard page) and redirect to the destination URL, such as window.location.href= "http://localhost:8889/app/dashboard"
. It is now required that the URL must not contain sessionId. After redirecting to the dashboard page, the URL is http://localhost:8889/-sharp!/app/dashboard
, is normal, there is no sessionId;, but when the user clicks the browser back button, go back to the home page, where the URL is http://localhost:8889/?sessionId=4724-3551655957868--736132069sh-sharp!/app/home
. In order to resolve the problem of session in the URL when fallback to the home page.
my current idea is that when users redirect from the login page to the home page, use the window.history.replaceState ({}, "http://localhost:8889/-sharp!/app/home")
, of the history
object to change the url of the current path to http://localhost:8889/-sharp!/app/home
, so that when the user clicks the browser back button from the dashboard page, the URL no longer contains session.
however, after I used the above action in case of a problem, I even jumped to the dashboard page and became http://localhost:8889/?sessionId=4724-3551655957868--736132069sh-sharp!/app/dashboard
. I wonder why the address bar hasn"t changed after changing the browser history list.
there are students who know, please give me some advice, thank you!