Skip to content

Remove sensitive data from url, but keep state on refresh #2398

Closed Answered by FaimMedia
FaimMedia asked this question in Help and Questions
Discussion options

You must be logged in to vote

Apparently there is a state property to attach metadata to the History API, so something like this works perfectly:

{
	path: '/password/:hash',
	name: 'password-redirect',
	redirect: (to: RouteLocationGeneric): RouteLocationRaw => ({
		name: 'password',
		state: {
			hash: to.params.hash,
		},
	}),
},
{
	path: '/password',
	name: 'password',
	component: Password,
}

In the Password component, the hash property in the state will be present, even on refresh:

const hash = history.state.hash?.toString();

console.log(hash);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by FaimMedia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant