How to add Service Binding to NuxtHub project
Hello!
I am doing a project with nuxthub and I need to add the "service binding" to call other workers directly.
In the CF documentation, they are declared in the "wrangler" file, but since I cannot modify it with NuxtHub, I would like to know how to add them.
https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/
7 Replies
I don't think NuxtHub currently supports these bindings automatically
And wouldn't there be some way to modify, even manually, some file, so that it adds that information to the "Wrangler" file?
I just need to add the information to that file for it to be recognized by CF.
If I can't, I would have to stop using nuxthub until they add this functionality and I prefer not to stop using it hahaha
ohb00 has been warned
Reason: Posted an invite
ok well thats absurd as its a link to NuxtHub discord
I was going to say, I think you can add the Binding in the Cloudflare dashboard but it'll disappear with the next deployment. It might be possible to add support if you're willing to hack onto the https://github.com/nuxt-hub/core package. I think there are plans in the future for more bindings but none yet
You should ask in the NuxtHub discord, but I'm not allowed to post an invite apparently
Something like this: https://github.com/nuxt-hub/core/pull/173
You'd basically just need to extend this function I think: https://github.com/nuxt-hub/core/blob/3eda06a7fbe76c5e07e115dbdbef419fd0312e66/src/utils/wrangler.ts#L3
i will check it tomorrow, thx for the links 🙂
OK, I've already been testing.
By modifying that file, I have managed to get the ‘Worker2Worker’ to work correctly locally.
To make it work once uploaded to Cloudflare, I had to add it manually from CF to the project. As NuxtHUB doesn't support it, it doesn't overwrite it between deploys either, so once configured it stays working without any problem.
At least, it is a workaround that allows to keep working with nuxthub and external workers.
node_modules/@nuxthub/core/dist/module.mjs
Thanks @bryce for ur help 🙂