nitro
nitro copied to clipboard
feat: add cloudflare-pages preset
🔗 Linked issue
#196
❓ Type of change
- [ ] 📖 Documentation (updates to the documentation or readme)
- [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
- [ ] 👌 Enhancement (improving an existing functionality like performance)
- [x] ✨ New feature (a non-breaking change that adds functionality)
- [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
📚 Description
Related to discussions #110 #196, a few in nuxt/framework
This PR intends to add a preset for Cloudflare Pages Functions - which is currently in Open Beta. Docs can be found at https://developers.cloudflare.com/pages/platform/functions/ .
Pages Functions are based on the modules worker type, so a different deployment preset will be needed.
update since first drafted, removed no longer relevant beta warnings
Functions are still in beta, however Direct Upload is now available for Pages, and I fixed all the issues I could find.
update again
Docs have now been updated (feedback welcome), the newest version of std-env should allow for automatic detection (only via git integration).
Have a good day.
📝 Checklist
- [x] I have linked an issue or discussion.
- [x] I have updated the documentation accordingly.
Hey @DaniFoldi 👋
Do you need help to test / finish this one?
I'm currently investigating to migrate to Cloudflare pages and I require this preset.
Hi!
I started writing the docs for the preset earlier today, so it should be ready today or tomorrow - the one remaining thing after this PR will be figuring out how to give api routes the request context.
Codecov Report
Merging #210 (abe5fd5) into main (5356f62) will increase coverage by
0.08%. The diff coverage is42.30%.
@@ Coverage Diff @@
## main #210 +/- ##
==========================================
+ Coverage 53.48% 53.57% +0.08%
==========================================
Files 54 54
Lines 3468 3494 +26
Branches 368 368
==========================================
+ Hits 1855 1872 +17
- Misses 1258 1267 +9
Partials 355 355
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/utils/index.ts | 23.52% <0.00%> (-0.82%) |
:arrow_down: |
| src/presets/cloudflare.ts | 63.63% <44.00%> (+11.00%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
@tuarrep I believe it's ready for testing, and feel free to leave any feedback on the docs as well. (vercel had a problem deploying, but doesn't tell what the problem was, so if it's something that I messed up (probably) could someone with access let me know?
does this mean by adding ./server/api/function.js and with git integration the preset will be auto set as cloudflare_pages, and the /function directory will be created with the function.js api? I have tested it here, and while the function folder is created, no function is actually deployed on cloudflare network . Tried running CF_PAGES=1 npm run generate in this stackblitz terminal https://stackblitz.com/edit/github-dxg5qg?file=server%2Fapi%2Fcustomer.get.js
Updated : Changed cloudflare build settings to npm run build , this does seem to pick up the /server/api/[routes] and inject them into /functions/[[path]].js However, for some reasons only GET requests are working, POST requests are getting 405 Method not allowed -- anyone else have better results?
Seeing same issue with non-get requests returning 405