SolidJSS
SolidJSโ€ข3y agoโ€ข
1 reply
Grahf

Protected route dynamic route that has to match certain parameter

I have a dynamic route for a user. The file route looks like this: routes/(home)/user/[user]/(user).jsx
It's protected so you can only navigate it to when logged in. BUT.... since it's a dynamic route you can go to like: http://localhost:3000/user/kdjfhdjkf and it will load the same page as http://localhost:3000/user/grahf

I think I'd like the page to load if and only if the parameter mathes the current logged in users name. In the (user).jsx component should I just check if the logged in username equals the parameter? If it doesn't then redirect to '/'?
Was this page helpful?