#Redirecting the client to another page

12 messages · Page 1 of 1 (latest)

lament trail
#
  1. Client makes a request to /api/auth/signup with an email and password
  2. Server reads the data, creates the user and then sends an email confirmation
  3. I then want the client to be redirected to /auth/confirm-signup

My problem is that if I redirect the client, the request is a "POST" and not a "GET" that will show the client the confirm signup page.

Any ideas on how I could solve this ?

fair citrusBOT
#

🔎 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)

lament trail
#

Ideally I'd want the server redirecting the user to the confirm-signup page. But the only thing that comes to my mind is to have the client navigate to the page with a router.push or something

thin lance
#

Correct, you can't redirect the user with a fetch on the client side. Use router.push instead

lament trail
#

I see, just to be 100% certain.

There's no way for me to redirect the user from the server to a "confirm-signup" page, right ?

I hope my question is clear

#

Here's how I want the flow to take place from the user's perspective:

  1. I'm at /auth/signup
  2. I type in my password, and email
  3. I submit and make a request to /api/auth/signup
  4. If my credentials are good, I want to see the confirm-signup screen. So I need to get redirected to it

So, the redirect can only be performed by the client by using router.push() or can the server somehow redirect me too ?

thin lance
#

True, unless the user directly open /api/auth/signup (if it is a GET API endpoint), they won't get redirected

#

because that will be awful if opening a request can cause redirection on the client side

lament trail
#

Copy copy If there's any piece of documentation you suggest I read so I can get a better understanding of these mechanisms please let me know

Otherwise, thank you very much for your help

thin lance
#

You can use follow in order to redirect the user, but that ignores client-side cache. With router.push, you can reuse the cache, resulting a better performance during redirection.

lament trail
#

I see, thank you again