netlify / remix-template

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

Netlify Functions Template Errors when running netlify dev #93

Closed nickytonline closed 1 year ago

nickytonline commented 1 year ago

Describe the bug

When running ntl dev for the Netlify Functions template it errors out with Error: remix dev is not supported for custom servers.

To Reproduce Steps to reproduce the behavior:

  1. Run npx create-remix --template netlify/remix
  2. Follow the steps in the Remix CLI
  3. Choose TypeScript or JavaScript, it doesn't matter
  4. When prompted from the Remix CLI, choose to use Netlify Functions
  5. Switch to the root directory of the generated project in your shell of choice
  6. Run ntl dev
  7. The following error occurs:
Error: remix dev is not supported for custom servers.
    at Object.serve (/Users/yo/dev/issues/remix-func/node_modules/@remix-run/dev/dist/devServer/serve.js:41:11)
    at Object.dev (/Users/yo/dev/issues/remix-func/node_modules/@remix-run/dev/dist/cli/commands.js:204:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async dev (/Users/yo/dev/issues/remix-func/node_modules/@remix-run/dev/dist/cli/run.js:187:3)
    at async Object.run (/Users/yo/dev/issues/remix-func/node_modules/@remix-run/dev/dist/cli/run.js:464:7)
◈ Command failed with exit code 1: npm run dev. Shutting down Netlify Dev server

Expected behavior

Running ntl dev for the Netlify Functions templated project should start the site for local development.

To fix this, add the following to the remix.init/netlify-toml file

[build]
command = "remix build"
publish = "public"

+ [dev]
+ command = "remix watch"
+ port = 3000

[[redirects]]
from = "/*"
to = "/.netlify/functions/server"
status = 200

[[headers]]
for = "/build/*"

[headers.values]
# Set to 60 seconds as an example. You can also add cache headers via Remix. See the documentation on [headers](https://remix.run/docs/en/v1/route/headers) in Remix.
"Cache-Control" = "public, max-age=60, s-maxage=60"

This is how it is set in the template currently residing in the Remix repo. https://github.com/remix-run/remix/blob/main/templates/netlify/netlify.toml#L5-L7

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

nickytonline commented 1 year ago

Fixed via #95