I would like to delete the previous history entry in Vue-Router, is that even possible?? The solution must work in Vue-Router 4.x, and ideally in 3.x as well.
The scenario that I'm implementing here is that a user does:
pageA -> pageA:edit -> pageB
When hitting "back" at pageB, I want to go to pageA (regular, non-edit) instead.
I know that I could instead of a push to history of the page A:edit page, simply do a replace. However, it feels more natural that when hitting back in the A:edit page, you are returned to the regular non-edit page (there already is a check for changes in the beforeUpdate route guard, so that's covered).
Actually, the API mentions that it is impossible to clear (and I infer from that also to remove from) the session history. Full text:
"There is no way to clear the session history or to disable the back/forward navigation from unprivileged code. The closest available solution is the location.replace() method, which replaces the current item of the session history with the provided URL."
https://developer.mozilla.org/en-US/docs/Web/API/Window/history
Unless someone knows a way, we'll have to accept it's impossible.