Server
Answered
American black bear posted this in #help-forum
American black bearOP
Hello, I'm trying when someone is verified so that will say to him "Verification succeeded! Please wait..." and that will return him to website. How im doing this?
setTimeout(() => {
NextResponse.redirect('http://localhost:3000/');
}, 2000);
return NextResponse.json('Verification succeeded! Please wait...', { status: 200 });Answered by Ray
I think you could use server action and set the cookies, and the page show "Verification succeeded! Please wait..." and do the redirecting
28 Replies
American black bearOP
i still don't understnad
..
i don't have a way to do this
I tried with try and finally and still not working
@American black bear Hello, I'm trying when someone is verified so that will say to him "Verification succeeded! Please wait..." and that will return him to website. How im doing this?
ts
setTimeout(() => {
NextResponse.redirect('http://localhost:3000/');
}, 2000);
return NextResponse.json('Verification succeeded! Please wait...', { status: 200 });
where are you trying this? In the route handler?
@Ray where are you trying this? In the route handler?
American black bearOP
Im trying when the user is veriflied so that will say to him "Verification succeeded! Please wait..." and that will return him to back to home
@Ray yes I meant the code
American black bearOP
on route.ts, do you want i send the code?
@American black bear on route.ts, do you want i send the code?
oh you should do it on the page.tsx
@Ray oh you should do it on the page.tsx
American black bearOP
how? i can't to do json an page.tsx
what do you mean can't do json?
@American black bear how? i can't to do json an page.tsx
could you show the code on page.tsx
American black bearOP
I did
return NextResponse.json('Verification succeeded! Please wait...', { status: 200 }); an the route.ts@Ray could you show the code on page.tsx
American black bearOP
i didn't made page.tsx , because i thought i can't to do json like this:
@American black bear I did `return NextResponse.json('Verification succeeded! Please wait...', { status: 200 });` an the route.ts
after the return, the request is finished for the route.ts and it can't send the response again
@Ray after the return, the request is finished for the route.ts and it can't send the response again
American black bearOP
ah, so i need to let this redirect to page.tsx verifly?
@American black bear ah, so i need to let this redirect to page.tsx verifly?
it can be done with react
@Ray it can be done with react
American black bearOP
what do you mean?
show the code you have on your page.tsx
and i will show you
American black bearOP
i still didn't made page.tsx so wait
@Ray and i will show you
American black bearOP
But if im doing
that can't be json..
function page() {
return (
<div>Verification succeeded! Please wait...</div>
)
}that can't be json..
what are you trying to do?
@Ray what are you trying to do?
American black bearOP
redirect with Cookie session (user is verified)
@Ray what do you mean can't be json?
then what you want to do with json? I don't get it
@Ray then what you want to do with json? I don't get it
American black bearOP
nvm i was thinking to let route.ts return json and redirect
but my question how im let route.ts send to page.tsx the info like
Server send to page about what he got -> page.tsx "Verification succeeded! Please wait..." + Cookie session
but my question how im let route.ts send to page.tsx the info like
Server send to page about what he got -> page.tsx "Verification succeeded! Please wait..." + Cookie session
I think you could use server action and set the cookies, and the page show "Verification succeeded! Please wait..." and do the redirecting
Answer