fair-rose
fair-rose7mo ago

question

Hello, I've a question, when i submit login the redirect doesn't work and still on.same page !
No description
3 Replies
kapa.ai
kapa.ai7mo ago
Hi @khalid_Hosni. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided, there could be several reasons why the redirect isn't working after login. Here are a few things you can check: 1. Check your useForm redirect property: By default, after a successful mutation, useForm will redirect to the "list" page. To redirect to a different page, you can either use the redirect function to programmatically specify the destination, or set the redirect property in the hook's options. Here is an example of how to do it:
const {
refineCore: { onFinish, redirect },
} = useForm();

const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const data = await onFinish(formValues);
redirect("show", data?.data?.id);
};
const {
refineCore: { onFinish, redirect },
} = useForm();

const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const data = await onFinish(formValues);
redirect("show", data?.data?.id);
};
(Source: Refine Documentation (https://refine.dev/docs/packages/react-hook-form/use-form#redirect-1)) 2. Check your authProvider check method: If you're using async code in your authProvider check method, it might be causing issues with the redirect. There's a known issue where the user is redirected to the first resource defined on the refined resources instead of the custom redirect path specified in the login method. This is caused because an API call is made to verify if the JWT is valid within the check method, which is automatically executed after login. If this is the case, you might want to adjust your check method. (Source: Github Issue (https://github.com/refinedev/refine/issues/4782)) 3. Check your routing: The redirect will only work if you have routerProvider defined in your <Refine> component along with the proper resource definition with routes and actions. (Source: Refine Documentation (https://refine.dev/docs/data/hooks/use-form#redirect-)) If you're still having issues, it would be helpful to provide a minimal reproducible example so we can better understand the problem. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@691983313354752050> kapa.ai is still learning and improving, please let us know how it did by reacting below
foreign-sapphire
foreign-sapphire7mo ago
Hello @khalid_Hosni, help bot can't read screenshots. Please try to describe your problem in details with text.'