Res.sendFile(path.resolve(_dirname, './client/build', 'index.html')) All other GET requests not handled before will return our React app server/index.jsĬonsole.log(`Server listening on $) We'll use Express to create a simple web server for us which runs on port 3001 if no value is given for the environment variable PORT (Heroku will set this value when we deploy our app). In it, we'll place a single file, out of which we'll run our server: index.js. Our server code will live in a folder of the same name: server. This will create a package.json file which will allow us to keep track of all our app scripts and manage any dependencies our Node app needs. To create our Node project, run the following command in your terminal: npm init -y Then, drag that folder into your code editor. Step 1: Create your Node (Express) backendįirst create a folder for your project, called react-node-app (for example). This is necessary for deploying our application with Heroku.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |