title: App built on React (frontend) and Node Express on the same port (Stripe integration)?
body: <p>I have an existing online shop app created with React on the front end and I am trying to integrate STRIPE as payment method using NODE express on backend. I would like to start them on the same port and I tried with the proxy in package.json and by serving index.html as static file but it doesnt work.</p>
  <p>I do serve index.html as static file but it doesnt seems to read anything else except the html.
  Here is my code:</p>
  <p>server.js</p>
  <pre><code>const express = require('express');
  require('dotenv').config('.env');
  const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
  const path = require('path')
  import Products from './src/components/Products';
  import CartItem from './src/components/context/cartProvider';
  
  
  const app = express();
  
  // I am trying to serve the whole React app as static file
  app.use(express.static('public'));
  
  app.get('/', (req, res) =&gt; {
      res.sendFile(path.join(__dirname, 'public', 'index.html'))
    })
  
  
  
  
  // ENDPOINTS FOR SESSION HERE
  
  app.post(&quot;/create-checkout-session&quot;, async (req, res) =&gt; {
  
  
  
      const session = await stripe.checkout.sessions.create({
        payment_method_types: [&quot;card&quot;],
        line_items: [
          // Here we have to send clonedCart[] as body
        ],
        mode: &quot;payment&quot;,
        success_url: &quot;https://example.com/success&quot;,
        cancel_url: &quot;https://example.com/cancel&quot;,
      });
    
      res.json({ id: session.id });
    });  
  
  
  
  app.listen(4000, () =&gt; console.log('Server is running on port 4000'))
  </code></pre>
  <p>In package.json I have added the following line:</p>
  <pre><code>  &quot;proxy&quot;: &quot;http://localhost:4000&quot;,
  </code></pre>
  <p>Worth naming that React is execute on the default port :3000</p>