title: Deploying React (3000) and Express (8000) app on the apache server
body: <p>I have created a React+Express application using the commands <code>npx create-react-app client</code> for React and <code>npx express-generator api</code> for the express backend. Both client and API are under the same folder <code>application</code>.</p>
  <p>The react application is running on the port 3000 and I have changed the port of express app to use port 8000 in the <code>/bin/wwww</code>.</p>
  <p>In the express application I have crated a route in <code>routes/testAPI.js</code>,</p>
  <pre><code>router.get(&quot;/&quot;, function(req, res, next) {
      res.send(“API is working properly”);
  });
  </code></pre>
  <p>And in app.js file I have used the route to handle request,</p>
  <pre><code>let testAPIRouter = require(&quot;./routes/testAPI&quot;);
  app.use(&quot;/testAPI&quot;, testAPIRouter);
  </code></pre>
  <p>Now in the react application inside the App.js file I have called the API and updated the content of <code>&lt;p&gt;{this.state.apiresponse}&lt;/p&gt;</code>.</p>
  <p>App.js file,</p>
  <pre><code>class App extends React.Component{
     constructor(props){
         super(props);
         this.state = {
            apiResponse : &quot;&quot;,
         }
      }
      apiCall = () =&gt; {
         fetch(&quot;http://localhost:8000/testAPI&quot;)
          .then(res =&gt; res.text())
          .then(res =&gt; this.setState({ apiResponse: res }));
      }
      componentWillMount = () =&gt; {
         this.callAPI();
      }
      
      render(){
          return(
            &lt;div&gt;
                &lt;p&gt;{this.state.apiResponse}&lt;/p&gt;
            &lt;/div&gt;
      )
     }
   }
  </code></pre>
  <p>My issue is to deploy this application on an apache server. As I'm running the express and react at different ports(3000 and 8000). I can build the react app using <code>npm run build</code> which will create static build files for react. But, how can I build the express app to use with react?
  Is it so moving the express files to the server and always run the application there at port 8000?</p>
  <p>I have successfully abled to run both at time using concurrent. I can run the application using <code>npm run dev</code>. But how to build the application and serve from apache?</p>
  <p>Thanks in advance.</p>