The situation
After a user registers on our website, they receive an e-mail with a link to our homepage with verification token. Once a user clicks on the link, enters the page and sees a welcome modal. The token is silently removed from the url and history without the page being refreshed. This avoids users triggering a "Token already verified" message when pressing the back button or refreshing the page. When the user closes the welcome modal, the page is also refreshed to log them in.
We do this using history.replaceState({}, pageTitle, '/')
, which should be supported on all browsers according to Mozilla's documentation.
The issue
All browsers on mobile and desktop follow this behavior, except Chrome on mobile, which completely ignores the function and leaves the token in the url. This means that when users close the welcome modal and the page refreshes to log them in, they see a "Token already verified" message.
I'm evading this by, instead of reloading the page, "redirecting" the user to the same url without the token after closing the welcome modal.
The question
Does Chrome browser on mobile support history.replaceState()
and am I doing something wrong in my code or does Chrome not support this API on mobile?
question from:
https://stackoverflow.com/questions/65887555/history-replacestate-not-working-on-chrome-mobile-browser 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…