Build Nuxt for CF Worker and postgre
Hello, I'm trying to deploy a nuxt 3 app on CF workers which use postgre module and even after using
compatibility_flags = [ "nodejs_compat" ]
or compatibility_flags = ["nodejs_compat_v2"]
in the wrangler.toml
I hit the error :
Any idea on how to fix this ?3 Replies
Hi @gabrielstuff. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, I don't have enough specific information to fully address your issue with deploying a Nuxt 3 app on Cloudflare Workers using a PostgreSQL module. However, I can provide some general insights and suggestions based on related information:
1. The error you're encountering seems to be related to the PostgreSQL module trying to use Cloudflare-specific features that are not fully supported or resolved in your current configuration.
2. Cloudflare Workers have some limitations when it comes to certain Node.js modules and features. The
nodejs_compat
flag you've tried is a step in the right direction, but it may not be sufficient for all Node.js modules.
3. According to the Adapters documentation (https://h3.unjs.io/adapters/cloudflare), Nuxt applications can be hosted on Cloudflare Workers using the Web Adapter. However, this documentation doesn't specifically address PostgreSQL integration.
4. One possible workaround could be to use a different database solution that's more compatible with Cloudflare Workers, such as Cloudflare's own KV or R2 storage solutions. The Cloudflare driver documentation (https://unstorage.unjs.io/drivers/cloudflare) provides information on how to use these storage options with Nuxt.
5. If you must use PostgreSQL, you might need to consider alternative deployment strategies or serverless platforms that have better support for Node.js database modules.
Unfortunately, the knowledge sources don't provide a direct solution to your specific error. You might want to consider reaching out to the Nuxt or Cloudflare community forums for more targeted assistance with this particular setup.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@213659913149218817> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
ok, even if response was not that good, It gives me the idea to look a bit at nito option.
I can now build and deploy using :
Some reading here: https://nuxt.com/docs/getting-started/configuration#external-configuration-files and there: https://github.com/nitrojs/nitro/issues/178, https://github.com/nitrojs/nitro/issues/1967