-
Hi all, I was looking to make a redirect from a loader in a route to the root page with some data. But data seems to get lost in the redirect, as it arrives with null value in the body. // some_page.ts
export const loader: LoaderFunction = async ({ request }) => {
const userLogged = await isUserLogged(request);
if (!userLogged) {
const locale = detectLocale({ url: new URL(request.url) });
return new Response(JSON.stringify({ protectedRouteAccessAttempt: true }), {
status: 302,
headers: {
Location: `/`
}
});
}
return null;
};
// root.ts
export const loader: LoaderFunction = async ({ request }) => {
console.log(request.body) // null
return null;
}; |
Beta Was this translation helpful? Give feedback.
Answered by
sergiodxa
Apr 20, 2022
Replies: 1 comment 1 reply
-
Two things are happening here.
There're two way you could pass data from a redirect to another loader.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
machour
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Two things are happening here.
There're two way you could pass data from a redirect to another loader.