-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Closed
Labels
Description
What version of React Router are you using?
6.4.1
Steps to Reproduce
Create a browser router with a basename, and add a route with an action and a form:
index.js:
const router = createBrowserRouter([
{
path: '/',
element: <App />,
action: action
},
], { basename: 'foo' })
app.js:
function action({ params }) {
console.log('foo')
}
function App() {
return (<Form method='post'>
<button type='submit'>submit</button>
</Form>)
}
The form posts to '/' instead of 'foo/'
A work around is specifying the action path with the basename:
{ /* other code */ }
<Form method='post' action ='foo/'>
<button type='submit'>submit</button>
</Form>
{ /* other code */}
Expected Behavior
The expected behaviour is that the basename will be added before the action url of the form (according to the docs this is the current path)
Actual Behavior
The actual behaviour is that the path to the route is evaluated without taking the basename into account.