Next.js Discord

Discord Forum

Is there a way for mask the frontend url in nextjs ?

Answered
Barbary Lion posted this in #help-forum
Open in Discord
Avatar
Barbary LionOP
i wanna mask the url
ex - http://localhost:3000/asd/123123123123131/234234234234234/
i wanted http://localhost:3000/asd/23/45
so only in frontend i wanna change them

8 Replies

Avatar
you can either use window.history.pushState or window.history.replaceState. Both should work fine. You can get code example from here: https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#using-the-native-history-api

Keep in mind, that if you doing this for security reasons, that this won't be secure.
Avatar
Barbary LionOP
i only want it to change the display of url not the functioning like other framework have hiding url masking the real url and showing different
Avatar
Answer
Avatar
@Barbary Lion solved?
Avatar
Barbary LionOP
Yes
Avatar
which solution do you use now?
Avatar
Barbary LionOP
The next rewrites one window one have some issue when i implemented