netlify / remix-template

Deploy your Remix site to Netlify
83 stars 27 forks source link

POST requests on dev server gives 404 #136

Closed hejmartin closed 8 months ago

hejmartin commented 8 months ago

Describe the bug POST requests against the Netlify dev server responds with a 404 error with Function not found...

To Reproduce Steps to reproduce the behavior:

  1. Run npx create-remix@latest --template netlify/remix-template
  2. Select Netlify Functions when prompted by installer
  3. Create a new route ./app/routes/edit.tsx with a <Form method="POST"> and an action function (see example below)
  4. Start server using netlify dev
  5. Open localhost:8888/edit in browser
  6. Post form
// app/routes/edit.tsx
import { ActionFunctionArgs } from "@remix-run/node";
import { Form } from "@remix-run/react";

export default function Edit() {
    return (
        <Form method="POST">
            <label>
                Title
                <input />
            </label>
            <button type="submit">Save</button>
        </Form>
    )
}

export async function action({ request }: ActionFunctionArgs) {
    return {
        message: "This is a message from the server",
    }
}

Expected behavior The page on port 8888 should not crash, it should behave the same as when opening localhost:3000, i.e. the Remix dev server, where the POST request works fine. Also, PUT requests seem to work fine on both ports.

I expect to be able to run the netlify dev server locally, as I need to run certain rewrites and redirects specified in netlify.toml.

Screenshots On port 3000, the POST works:

image

On port 8888, the POST does not work:

image

Desktop:

ascorbic commented 8 months ago

Fixed in latest version