Skip to content

Netlify Functions Template Errors when running netlify dev #93

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

Closed
nickytonline opened this issue Feb 25, 2023 · 1 comment · Fixed by #95
Closed

Netlify Functions Template Errors when running netlify dev #93

nickytonline opened this issue Feb 25, 2023 · 1 comment · Fixed by #95

Comments

@nickytonline
Copy link
Contributor

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):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@nickytonline
Copy link
Contributor Author

Fixed via #95

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