Hi I want to create a MERN app out of create-react-app, but I am running into a dilemma since the bundle launches the app on a server. I want to connect the app to mlab using Mongoose and set up some routing for the db. Is that possible?
Any direction or advice would be greatly appreciated.
Peter
PS I tried calling my mongoose model directly inside my src file, because it seems that everything in that folder is served over a server. The error I got was pretty interesting. I discovered what a disaster it is to try to compile MongoDB, which is all ready in C. Needless to say it was a late night. Anyway, any advice would be greatly appreciated. Thank you.
PS I tried calling my mongoose model directly inside my src file
This wouldn鈥檛 work. Create React App bundles your JS in files to be executed by the browser. There is no server side component to it: it just produces HTML+JS+CSS which you can serve any way you like.
For example integration with Express or Rails, please check these articles:
https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/
https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/
I hope this helps!
Most helpful comment
This wouldn鈥檛 work. Create React App bundles your JS in files to be executed by the browser. There is no server side component to it: it just produces HTML+JS+CSS which you can serve any way you like.
For example integration with Express or Rails, please check these articles:
https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/
https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/
I hope this helps!