#NextJs Redirect - Not working?

2 messages · Page 1 of 1 (latest)

fickle slate
#

How can I force a redirect to work reliably? Adding random parameters to make it function isn't the right approach. I find the redirect behavior to be quite unpredictable. Any assistance would be appreciated. I just need to enforce a redirect while ignoring the cache and other factors. Thanks!

  useEffect(() => {
    setNextUrl(searchParams.get('nextUrl') || urls.site.home);
  }, [searchParams]);

  // redirect if already logged in
  useEffect(() => {
    if (state.isLoggedIn) {
      logger.info('Login successful', nextUrl);
      router.push(`${nextUrl}?protected=somerandomstring`);
    }
  }, [state, nextUrl, router]);```
dawn prismBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)