-
Notifications
You must be signed in to change notification settings - Fork 91
Description
When migrating NuxtHub projects to Cloudflare Workers, there are several critical issues that prevent a lot of necessary features from working correctly. Problems include the cache key not linking to KV storage, the suggestion to create a custom wrangler.jsonc, and preview/build inconsistencies. These issues block successful migration and deployment, which means that my projects are currently stuck.
This issue is both a bug report and a feature request, as a result, though I think the request is more important.
Example
For the last (public) project I need to convert, NuxtPress, there seems to be a few inconsistencies with the migration instructions, what actually needs to happen, and the various issues faced with migration:
nuxi devno longer work out of the boxcachekey does not work as intended (see below)- Nitro usually generates a
wrangler.json, this time we need to provide our ownwrangler.jsonc - For a template project like this, it worked because NuxtHub automatically generated the bindings for me; that's no longer the case, and I would need some help on a new solution
Feature Request
Extend Sunset Deadline
Due to these critical development bugs that will likely need to be resolved in order for conversion to be 100% (and hopefully not lose any necessary progress when NuxtHub Admin is no longer accessible), I am hoping you can extend the conversion deadline until these bugs are fixed. Conversion is next-to-impossible without nuxi dev and/or nuxthub preview.
Improve the Cloudflare Conversion Guide
Having users create their own wrangler.jsonc is unnecessary, given that nitro generates your own wrangler config. This also breaks deployment, because nitro already creates a .wrangler/deploy/config.json file that points to the generated config. This means that, when you run nuxt build, and try and run wrangler deploy, it will throw an error because they'res two different wrangler configurations.
Simply building it and not creating your own wrangler config is enough. I would highly recommend adding that, if you use GitHub Actions, do something like this:
# no working directory or config needed, just the auth
- name: Deploy to Cloudflare Workers
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}Bugs
cache key does not work
With my other successful conversion project, @earth-app/crust, the cache key no longer works as intended:
ℹ hub:cache using cloudflare-kv-binding driver nuxt:hub 7:45:33 PM
ℹ Nuxt Icon server bundle mode is set to local 7:45:34 PM
[7:45:34 PM] ✔ Nuxt Icon discovered local-installed 17 collections: bx, carbon, cib, circum, eos-icons, game-icons, healthicons, heroicons, icon-park-outline, lucide, map, material-symbols, material-symbols-light, mdi, nimbus, ph, solar
ℹ Using cloudflare-dev emulation in development mode. 7:45:34 PM
✔ Vite client built in 63ms 7:45:35 PM
✔ Vite server built in 13ms 7:45:35 PM
✔ Nuxt Nitro server built in 832ms nitro 7:45:36 PM
ℹ Vite server warmed up in 0ms 7:45:36 PM
ℹ Vite client warmed up in 2ms 7:45:36 PM
Using vars defined in .env 7:45:37 PM
Using vars defined in .env.local 7:45:37 PM
ERROR [cache] Cache read error. [unstorage] [cloudflare] Invalid binding CACHE: undefined 7:45:44 PM
at getBinding (node_modules/unstorage/drivers/utils/cloudflare.mjs:9:11)
at getKVBinding (node_modules/unstorage/drivers/utils/cloudflare.mjs:25:10)
at getItem (node_modules/unstorage/drivers/cloudflare-kv-binding.mjs:29:23)
at asyncCall (node_modules/unstorage/dist/shared/unstorage.zVDD2mZo.mjs:9:26)
at Object.getItem (node_modules/unstorage/dist/index.mjs:151:14)
at get (.nuxt/dev/index.mjs:270:36)
at .nuxt/dev/index.mjs:345:25
at runNextTicks (node:internal/process/task_queues:65:5)
at listOnTimeout (node:internal/timers:569:9)
at process.processTimers (node:internal/timers:543:7)
In both development and production, the KV is never linked as apart of the generated nitro. This was likely just a missed feature, since setting the build to cloudflare_module generates a wrangler JSON for you. I think having users create their own wrangler.jsonc isn't necessary.
nuxi dev no longer work out of the box
Going back to the NuxtPress example, it's a similar bug to the previous example. Trying to convert the Database, KV, and cache storage all illicit the same unbounded error.
nuxthub preview does not recognize builds
Running nuxt build and then nuxthub preview does not work.
# nuxt build
# ...
Σ Total size: 4.38 MB (1.18 MB gzip)
ℹ Generated .output/server/wrangler.json 7:50:12 PM
ℹ Generated .wrangler/deploy/config.json 7:50:12 PM
ℹ Generated .output/public/_headers 7:50:12 PM
✔ You can preview this build using npx wrangler --cwd .output dev nitro 7:50:12 PM
✔ You can deploy this build using npx wrangler --cwd .output deploy nitro 7:50:12 PM
│ 7:50:12 PM
└ ✨ Build complete!
# bunx nuxthub preview
WARN NuxtHub Admin and CLI will be sunset on December 31st, 2025. Learn more at https://hub.nuxt.com/changelog/self-hosting-first. 7:50:20 PM
NuxtHub CLI 7:50:20 PM
ERROR Production build not found, please run npx nuxt build 7:50:20 PMFinal Notes
Congratulations on getting acquired by Vercel. This is a big step for NuxtHub, and I hope it goes far. I do think there are a few more loose ends that need to get fixed up before the entire service is sunset.