Hello guys I’m recently new using Nuxt. And I’m having a hard time to deploy an app that uses mongo driver to connect to my mongodb. I read about it and I understand that is not possible without realmjs to deploy to cloudflare. Since realmjs is deprecated now I’m looking for a different solution to deploy my app. I have access to a was account. What do you suggest do deploy my application. I took a look in nuxt documentation but I’m confused which option should I use here.
Thanks in advance for the help!
#project with MongoDB
13 messages · Page 1 of 1 (latest)
Hi. Hope you find the answers you need. May I ask if you're using any module like mongoose or nuxt-mongoose?
Hi. I'm using mongodb driver. no module
On the mongodb website they have two different courses.
One for mongoose, which still is useless because nuxt recommends nuxt-mongoose which is set up differently (https://learn.mongodb.com/learn/course/mongoose-odm-with-mongodb/learning-byte/learn?client=customer&page=1)
and one for standard mongo driver using Node.js.
https://learn.mongodb.com/learn/course/connecting-to-mongodb-in-nodejs/lesson-3-troubleshooting-a-mongodb-connection-in-nodejs-applications/learn?client=customer
This last one might be actually what can help you. You must be smarter than me to be brave enough to use standard library in nuxt. I am already lost in so many linked files and auto-imports, that I am either all-in nuxt or just go ahead and ditch it for vanilla js 🤣
Discover our MongoDB Database Management courses and begin improving your CV with MongoDB certificates. Start training with MongoDB University for free today.
Discover our MongoDB Database Management courses and begin improving your CV with MongoDB certificates. Start training with MongoDB University for free today.
Hi @peak snow , I'm guessing you meant AWS account 🙂
So what I can suggest is that you look at deploying to Amplify (https://docs.aws.amazon.com/amplify/latest/userguide/get-started-nuxt.html), seeing as it supports SSR now using Lambdas. Your MongoDB queries will probably be done server side as you don't want to expose your connection string and credentials publicly. I'd suggest setting up server api routes and look at deploying them with your Nuxt app on Amplify (worth noting that server routes are executed inline instead of a request with SSR).
There are other alternatives like Vercel as well but I don't know enough about them to give any advice.
If you're not keen on using Amplify and have an EC2 server available, you could also setup a Nginx reverse proxy to proxy requests to your nuxt app running on port 3000.
Yes correct. Aws account, with amplify and ec2. I think I’m gonna give it a go in amplify and see how it goes. To achieve the server using lambdas do I need a specific setting or something in nuxt or amplify? I’m gonna check the link you send and see if I can deploy. Otherwise I will move to ec2
Well some bad and good experiences and multiple projects with mongo lead me to use mongodb driver 😂
and actually mongo should work now - as well as many other TCP based connections: https://blog.cloudflare.com/workers-tcp-socket-api-connect-databases/
The Cloudflare Blog
Today, we are excited to announce a new API in Cloudflare Workers for creating outbound TCP sockets, making it possible to connect directly to databases and any TCP-based service from Workers.
ALEX BEVILACQUA
Cloudflare Workers is a great platform for deploying serverless JavaScript code, but has historically never supported raw sockets. In May of 2023 they announced support for a connect() API which allows TCP Sockets to be created within Workers, but is not a direct replacement for Node.js’ net.Socket API.
isn't amplify supposed to support Nuxt SSR with zero config?
yeahp, SSR works with zero config. I'm personally having trouble converting an SSR app to a static one, but that's not on this discussion 😛
setting up nuxt ssr with amplify is dead easy, as you will see from the link posted, the only important thing is to enable the ssr logging (helps with debugging too) so that the amplify app is created with WEB_COMPUTE platform instead of WEB