trpc-nuxt
trpc-nuxt copied to clipboard
Not working on Cloudflare Workers
It's not possible to run this when deployed on Cloudflare Workers. I'm getting the error global is not defined
. Might have something to do with how the fetch workers there. Maybe this two repos could be of help to solve the problem.
https://github.com/esamattis/trpc-cloudflare-worker https://github.com/valu-digital/npm-packages/tree/master/packages/trpc-fetch-api-adapter
Need to polyfill the global object
Need to polyfill the global object
Thanks got it working using https://www.npmjs.com/package/@ungap/global-this.
Now I'm having another problem with CORS. The endpoint can be called directly (example /trpc/hello
) but not with useAsyncQuery
in a page. Is this a limitation of Workers or how should I add the correct headers for this?
Thank you for the help!
Actually I'm dumb.. the worker tried calling the localhost trpc server in production. Everything works now, thanks for the awesome Nuxt TRPC implementation!
@wobsoriano Do have time for another question regarding running on Cloudflare Workers?
It seems that using useAsyncQuery
doesn't run on the server during SSR. Instead it runs on the client side and there is not data in the initial HTML sent from the server. Note that everything is working as expected when using the node preset.
@wobsoriano hi, do you have any update on my second issue?
Hey, just released v3. Probably fixes your issue @essarn
Yes it should work, looking forward to using the library with v10 support.