S
SolidJS3mo ago
Hussein

how to redirect in a "use server" function?

is there a way to redirect outside of cache, action and without useNavigate?
async function redirect() {
"use server";
// how??
redirect("/other");
}
async function redirect() {
"use server";
// how??
redirect("/other");
}
1 Reply
Madaxen86
Madaxen863mo ago
Try to return new Response with a location header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location
MDN Web Docs
Location - HTTP | MDN
The Location response header indicates the URL to redirect a page to. It only provides a meaning when served with a 3xx (redirection) or 201 (created) status response.
Want results from more Discord servers?
Add your server