Confused about which Cloudflare preset to use and basic setup for workers #2876
-
I am migrating an app deployed on Vercel to Cloudflare. But every step of the way, I encountered a new issue. At this point I decided to start from scratch and build it for CF. Available PresetsWhen you create a new Nuxt app, you get many Cloudflare presets, I understand there are two usable presets:
I want to use observability, cron, durable objects etc. in my app so I understand workers is the one for me. Wrangler Preset vs Nitro PresentThis is where it gets interesting: If I create worker for Nuxt based on CF's own recommended command nitro: {
preset: "./cloudflare-preset"
} And the preset generated by wrangler is: import { type NitroPreset } from "nitropack";
export default <NitroPreset>{
extends: "cloudflare",
exportConditions: ["workerd"],
output: {
dir: "{{ rootDir }}/dist",
publicDir: "{{ output.dir }}/public",
serverDir: "{{ output.dir }}/worker",
},
commands: {
preview: "npx wrangler dev",
deploy: "npx wrangler deploy",
},
wasm: {
lazy: false,
esmImport: true,
},
rollupConfig: {
output: {
entryFileNames: "index.js",
format: "esm",
exports: "named",
inlineDynamicImports: false,
},
},
}; And this is my
DifferencesNow:
So why are there differences between Cloudflare's preset and Nitro's own preset? And Why do I keep getting an error if I deploy with I have so many questions because the whole Cloudflare thing with Nitro looks so confusing, despite having read the whole Nitro + CF documentation and countless Github issues. Does anyone have any ideas? 🙏🏽 Sorry for tagging you here @pi0, but would be grateful to know what you think. Edit: Full codebase available here. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I am so sorry about your inconvenience in the migration path. Certainly please do not use the cloudflare (experimental) starter template, it is unsupported. Instead:
Let me know how it goes. |
Beta Was this translation helpful? Give feedback.
I am so sorry about your inconvenience in the migration path.
Certainly please do not use the cloudflare (experimental) starter template, it is unsupported.
Instead:
compatibilityDate
to2024-11-01
(or newer)Let me know how it goes.