TanStackT
TanStack14mo ago
1 reply
endless-jade

Redirect to another website if missing search params

Hello folks, from our main website we select the items etc and then user clicks on "Proceed" and they navigate to our SPA and we pass some search parameters like IDs, some flags, etc. All of them required, if one of them is missing we should redirect back to the main website they came from.

Currently if the paran validation fails, I just display the general error screen and validate if error.routerCode === "VALIDATE_SEARCH" is true, then redirect the user to our main website.

Is this the better approach? I dont wanna make our general error screen dirty, can I do the redirecting in the beforeLoad or something like that?
Was this page helpful?