I'm trying to recreate the instagram shallow routing logic, which looks like this:
instagram.com/p/cristiano.instagram.com/p/Cd0..., instead of being taken to detail page, user is presented with modalinstagram.com/p/cristiano.Here is how I'm trying to recreate this logic:
shallowRoutingOrigin is the page from where I am opening the modal:
could be either savedworkouts,discovery or u/${username}
const handleShallowRoutingClick = (documentId: string) => {
router.push(
`/${shallowRoutingOrigin}?documentId=${documentId}`,
`workoutpreview/${documentId}`,
{
shallow: true,
}
);
setModalIsOpen(true);
};
const handleModalClose = () => {
router.push(`/${shallowRoutingOrigin}`, undefined, {
shallow: true,
});
setModalIsOpen(false);
};
The following logic and desired effect works on savedworkouts and discovery pages, however when I try to open the modal from u/${username}, instead of masking. url as /workoutpreview/id1 it masks as /u/workoutpreview/id1 and I get 404 this page not found error.
What makes this logic not work on the user page?