《 Sarge 》
CDCloudflare Developers
•Created by 《 Sarge 》 on 3/13/2024 in #pages-help
Nuxt3 with D1 binding example
Hi there, I'm looking for a basic example of Nuxt3 working with a d1 database. Using the ./server/ folder instead of functions. From my understanding the binding should integrate, but I'm not finding good examples that are a straight install, configure and run. I have looked at this https://github.com/tlebeitsuk/nuxt-cloudflare-lucia example. But when I go to run it, it fails with an error that seems tricky to fix.
ERROR [worker reload] [worker init] Only URLs with a scheme in: file, data,
and node are supported by the default ESM loader. On Windows, absolute paths must be valid file://
URLs. Received protocol 'c:'
I have already got a Nuxt2 application working using the ./functions/ folder as the API. But I wanted to see if it is possible to use the native ./server/ folder hosted by nuxt for easier development.
Otherwise I need to run multiple terminals, hosting nuxt, and wrangler. Then use axios to proxy the API calls so they work on the same domain. That jus seems really complicated comparied to what I want to do. Basically I want the defineEventHandler( async (event) => {...} to pass the cloudflare d1 binding through the event.context object if possible. Running a single terminal to host it.
The command to host it would be something like this
wrangler pages dev --proxy 3000 --d1=database --persist-to \"../some-folder\" -- nuxt dev
If you have some examples that you can share I'd appreciate it. Or if I'm completely barking up the wrong tree let me know.1 replies
CDCloudflare Developers
•Created by 《 Sarge 》 on 2/19/2024 in #pages-help
Nuxt and d1 context reference missing
Hi there, I have a thread in the general discussing that doesn't seemt to be getting much love
https://discord.com/channels/595317990191398933/1207746743177969685/1207746745346293790
Could someone please help me help me work out what I'm missing here?
Need a 'Nuxt-on'pages' tag probably.
Thanks
1 replies