1

I took Stephen Grider's Udemy course on React and Redux. He walked us through building a basic Twitch clone that uses json-server as a backend database. I need to deploy an app like this, preferably using my Godaddy cPanel since I have a domain and hosting already purchased.

I have successfully deployed everything except for the json-server. The app works perfectly on my machine only since the project points to http://localhost:3001 and I have json-server running.

import axios from "axios";

export default axios.create({
  baseURL: "http://localhost:3001",
});

How can I deploy the json-server so the app can be accessed by anyone who visits my website? The closest I could find to getting an answer was this question but I am not using Heroku. Is it possible to deploy the json-server React app to Godaddy cPanel, or would I need to store the database using something other than json-server?

Trevor
  • 11
  • 4
  • Do you have shell access? (e.g. SSH) – Nathan Chu Nov 03 '20 at 13:06
  • If you are using cpanel most probably your server is not NodeJS based. If you server is NodeJs based and if you have right to install then json-sever can be installed. – kiranvj Nov 03 '20 at 13:10
  • @kiranvj If the OP has shell access then they could install nvm. (If godaddy allows port forwarding on their plan). And also I'm pretty sure that cPanel only supports Apache but has nginx in beta (no support for node) – Nathan Chu Nov 03 '20 at 13:11
  • This is shared hosting. I'll look into Heroku- I'm pretty new and had never heard of it before reading that question I linked. – Trevor Nov 03 '20 at 13:16
  • @nthnchu yes, I have shell access – Trevor Nov 03 '20 at 13:18
  • If you're on shared hosting, you should try heroku. Your package.json start script should be `json-server --watch db.json`, and your Procfile would be `web: npm start` – Nathan Chu Nov 03 '20 at 13:30
  • Okay, thank you I will try heroku – Trevor Nov 03 '20 at 13:37

0 Answers0