Skip to content
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

[Bug]: Form action path does not take basename into account #9416

Closed
nemjit001 opened this issue Oct 6, 2022 · 1 comment
Closed

[Bug]: Form action path does not take basename into account #9416

nemjit001 opened this issue Oct 6, 2022 · 1 comment
Labels

Comments

@nemjit001
Copy link

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.

@nemjit001 nemjit001 added the bug label Oct 6, 2022
@brophdawg11
Copy link
Contributor

I think this is a dup of #9347 which was fixed in 6.4.2. Please re-open if it's still not working for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants