#project with MongoDB

13 messages · Page 1 of 1 (latest)

peak snow
#

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!

calm vessel
#

Hi. Hope you find the answers you need. May I ask if you're using any module like mongoose or nuxt-mongoose?

peak snow
#

Hi. I'm using mongodb driver. no module

calm vessel
#

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 🤣

proven pollen
#

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.

peak snow
#

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

peak snow
knotty dagger
broken ingot
proven pollen
#

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