简体   繁体   中英

How to host reactJs(frontend) NodeJs(backend) and Mysql database

I have 2 separate projects. One is for frontend reactJs another for backend NodeJs and I am using mySQL database to fetch data from. My main issue is, I am not able to host this website on internet.

I tried using firebase hosting and was able to host frontend reactJs project. I still have NodeJs and MySql db that needs to be hosted in order for the website to function. Also, what changes do I need to make in the connection file to DB, from front end the api firing is done using axios (" http://localhost:3000 "). Do I need to change this as well? I am completely new to this hosting process.

It's great that you managed to deploy your front-end app. As you said now you have to also deploy the back-end one to which your React app is making requests. What I can recommend is to use an online hosting platform (I personally use DigitalOcean) and rent a Droplet which is basically a piece of a server running on Linux (or other OS) on which you have full control. You have to prepare the environment so that you can deploy both the database and the NodeJs app there.

After you succesfully prepare the environment and deploy your node app there you can use the Droplet's IPv4 concatenated with the port the app is using to send the requests from your React application. Example:

'instead of http://localhost:3000 use http://your_ipv4_adress:3000 '

I would recommend to use Ubuntu as the Droplet's OS as there are a lot of online tutorials on how to prepare the environment and deploy apps for different tools and frameworks.

Hope I helped you, cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM