-
-
Notifications
You must be signed in to change notification settings - Fork 40
Description
When using React Router with a basename that ends with a trailing slash, submitting a form managed by remix-hook-form triggers a client-side navigation instead of correctly submitting the form to the action.
Removing the trailing slash from the basename (e.g. /app instead of /app/) resolves the issue, but this has further implications with the way vite handles the basepath. In my case it will break my SPA because vite cannot resolve paths to client build assets anymore.
As a current workaround i have patched this part in the handleSubmit function:
const action = e?.currentTarget?.action.replace(
`${window.location.origin}${basename === "/" ? "" : basename}`,
"",
);by replacing the action string with a "/" instead of nothing:
const action = e?.currentTarget?.action.replace(
`${window.location.origin}${basename === "/" ? "" : basename}`,
"/",
);I am not sure if this has any implications with the way this library works, so i haven't submitted a PR yet. For now this seems to solve my issue but i'd love to see this being officially fixed in the library.