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

netlify_builder preset not working as expected (Netlify returning 405) #2946

Open
Stiropor opened this issue Dec 18, 2024 · 6 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@Stiropor
Copy link

Stiropor commented Dec 18, 2024

Environment

When building on Netlify:
node: 20.x
nitro: 2.10.4

Reproduction

https://stackblitz.com/edit/github-dlgsurlp-kv8uscif?file=server%2Froutes%2Findex.ts,server%2Fapi%2Ftest.post.ts

Github repo:
https://github.com/EngageFactory/nitro-swr-test

Describe the bug

When building on Netlify with netlify_builder preset ignores the swr setting

  routeRules: {
    '/api/**': { cache: false, swr: false },
  },

works in stackblitz but not on Netlify. It should build the api routes with normal netlify preset (understanding from nuxt/nuxt#19774 (comment)), otherwise netlify accepts GET only (https://docs.netlify.com/configure-builds/on-demand-builders/).
Netlify returns 405 method not allowed

Posting here as adviced by @danielroe on nuxt/nuxt#19774 where similar problem is being addressed.

Additional context

No response

Logs

No response

@pi0
Copy link
Member

pi0 commented Dec 18, 2024

Thanks for detailed issue.

Please consider using main netlify preset.

As of 2.10.0 release Nitro supports functions v2 format and automatically adds durable cache-control which is the new recommended approach from Netlify.

(we might update docs. /cc @serhalp)

@pi0 pi0 added documentation Improvements or additions to documentation and removed pending triage labels Dec 18, 2024
@Stiropor
Copy link
Author

Thanks @pi0 this worked exactly as we wanted, speed is now 500ms -> 50ms also API endpoints work as they should!

But if I understand correctly then netlify_builder is not even needed anymore, meaning this preset is then obsolete? I sugges it's then removed from docs (also Nuxt) to avoid confusion and errors.

@pi0
Copy link
Member

pi0 commented Dec 19, 2024

Yes we should do it from docs at least 👍🏼

@Stiropor Stiropor reopened this Dec 19, 2024
@Stiropor
Copy link
Author

Do I close the issue or do you need it for docs?

@serhalp
Copy link
Contributor

serhalp commented Dec 19, 2024

Yes I had originally removed the netlify_builder preset entirely in #2406 but we pulled that out of the PR to keep it non-breaking.

@pi0 can we remove it in v3?

@pi0
Copy link
Member

pi0 commented Dec 19, 2024

Yes we can drop it in v3 for sure.

For v2, removing preset would be a breaking change but i suggest use docs + a preset level warning to make people moving away from it. (if you have time to make a PR i would appreciate 🙏

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

No branches or pull requests

3 participants