-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid redirect with callback to absolute URI #10489
Comments
I want to be sure about the problem you meet:
Is it the right description? If so, I don't see a bug. You should either remove the trailing slash from 1 or the leading slash from 2. |
No, I never set basename, so it does not have the traling slash, u can see the code I posted from
so this code will not as expected const redirect = useRedirect()
redirect(() => `/resourceA/1/resourceB/2/resourceC/3`) |
Right, react-admin adds the slash after the basename. But then, why do you include a trailing slash in your redirect URI? |
Because your doc says so... https://marmelab.com/react-admin/useRedirect.html#useredirect Example 1 from docs import { useRedirect } from 'react-admin';
const DashboardButton = () => {
const redirect = useRedirect();
const handleClick = () => {
redirect('/dashboard');
}
return <button onClick={handleClick}>Dashboard</button>;
}; Example 2 from docs redirect((resource, id, data) => {
return data.hasComments ? '/comments' : '/posts';
}, 'posts', 1, { hasComments: true }); Example 3 from docs redirect(`/deals/${deal.id}/show`, undefined, undefined, undefined, {
_scrollToTop: false,
}); p.s I never said I can not do a workaround, but it is just wrong to add trailing slash without checking first if there is slash already |
You're right. Would you like to open a PR to fix |
What you were expecting:
Im using custom routes, passing
redirect
property toCreate
componentExpected to redirect to the absolute uri returned from the callback
/resourceA/1/resourceB/2/resourceC/3
What happened instead:
instead I was redirected to
/1/resourceB/2/resourceC/3
, according to the code ofredirect
function fromra-core
the result will be
<basename>//resourceA/1/resourceB/2/resourceC/3
the double slash is causing the issue I belive, I would expect the check for leading slash before concatinationEnvironment
The text was updated successfully, but these errors were encountered: