remix icon indicating copy to clipboard operation
remix copied to clipboard

Forms submits should default to index.tsx file if <route>.tsx doesn't exist (External requests work this way)

Open domSBM opened this issue 3 years ago • 1 comments

What version of Remix are you using?

1.6.3

Steps to Reproduce

  1. Create a route as follows:
  • api
    • v1
      • customers
        • index.tsx
  1. Try and submit to this route using useFetcher:

fetcher.submit(null, {action: "/api/v1/customers/", method: "get" })

  1. you will notice that the no network request is made (not even a 404)

  2. Updating the submit action:

fetcher.submit(null, {action: "/api/v1/customers?index", method: "get" })

OR

changing the route strucuture to this:

  • api
    • v1
      • customers
        • customers.tsx

Fixes the issue

However this is only an issue inside remix, and is impossible to debug from postman or any other HTTP client (e.g. web browser) on the account that any external requests defaults to index.tsx if customers.tsx doesn't exist

At minimum an error should be displayed inside remix

Expected Behavior

External requests should behave exactly the same as internal submit requests.

Actual Behavior

Submit inside remix behaves differently than external requests with no warning or error.

using the initial route structure and accessing the route /api/v1/customers/ in postman works as expected, however doesn't work inside remix

domSBM avatar Oct 20 '22 05:10 domSBM

I'm seeing something similar. When making a POST request with action: '/folder' it errors because root.tsx doesn't export an action. WIthout an action (submit(form, { method: 'post'})) the browser redirects to /folder?index.

assaf avatar Nov 02 '22 18:11 assaf

Converting this to a Proposal discussion, as per our Development Process.

machour avatar Jan 22 '23 18:01 machour