title: NodeJS Express API only returns index.html file on production?
body: <p>My original question: <a href="https://stackoverflow.com/questions/62391953/how-to-set-up-vuejs-routes-and-nodejs-express-api-routes">How to set up VueJS routes and NodeJS Express API routes?</a></p>
  
  <p>I got feedback that if <a href="https://stackoverflow.com/questions/52327143/serving-vuejs-builds-via-express-js-using-history-mode">Serving VueJS Builds via Express.js using history mode</a> question doesn't solve my issue, I need to ask a new question, so here I'm.</p>
  
  <p><strong>Problem:</strong><br>
  NodeJS (powered by express) API return always <code>index.html</code> - no matter what.</p>
  
  <p><strong>Notes</strong><br>
  - Works great on local<br>
  - API returns the <code>index.html</code> file only on production</p>
  
  <p>I'm super confused what can cause this?</p>
  
  <p>I place my Nginx configs in here as well, since I think it has something to do my production server since the issue only happens there:</p>
  
  <pre class="lang-js prettyprint-override"><code>server {
      root /var/www/example.com/client/dist;
      index index.html index.htm index.nginx-debian.html;
  
      server_name example.com www.example.com;
  
      location / {
          try_files $uri $uri/ /index.html;
  
          proxy_pass http://localhost:1234;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
      }
  }
  </code></pre>
  
  <p>NodeJS server:</p>
  
  <pre class="lang-js prettyprint-override"><code>// server.js
  const express = require("express");
  const app = express();
  const history = require("connect-history-api-fallback");
  const cors = require("cors");
  const bodyParser = require("body-parser");
  const path = require("path");
  const http = require("http");
  const server = http.createServer(app);
  
  app.use(cors());
  app.use(
    bodyParser.urlencoded({
      extended: true,
    })
  );
  app.use(bodyParser.json());
  
  app.get(`/user`, async (req, res){
    // Also, I have tested with res.json AND setting the content type manually
    return res.send({ test: 123 });
  });
  
  app.use(history());
  app.use(express.static(path.join(__dirname, "../client/dist")));
  app.get(`/`, (req, res) =&gt; {
    res.sendFile(path.join(__dirname, "../client/dist", "index.html"));
  });
  
  server.listen(1234);
  </code></pre>
  
  <p><strong>Problem:</strong><br>
  NodeJS (powered by express) API return always <code>index.html</code> - no matter what.</p>