title: How to serve static HTML files in Nest.js?
body: <p>I want to serve static HTML files which are in a <code>/dist</code> folder outside of the Nest project. <code>index.html</code> is loaded successfully but it fails to load any JS file (<code>404</code> error).</p>
  
  <p>I have a Node/Express.js project which uses </p>
  
  <pre><code>app.use('/', express.static('../client/dist'))
  </code></pre>
  
  <p>and it works perfectly fine.</p>
  
  <p>In the Nest project, however, </p>
  
  <pre><code>app.setBaseViewsDir(join(__dirname, '../../client/dist'))
  </code></pre>
  
  <p>does not do the trick.</p>
  
  <p>In the <code>AppController</code> I tried</p>
  
  <pre><code>import { Response } from 'express';
  
  @Get()
    get(@Res() res: Response) {
      res.sendFile('index.html', {
        root: '../client/dist',
      });
    }
  </code></pre>
  
  <p>But no luck.</p>
  
  <p>As mentioned, the <code>index.html</code> is loaded successfully. So the problem is not a wrong path. Neither is the problem wrong src-paths in the <code>index.html</code> because in the Express project the exact same files are used.</p>
  
  <pre><code>/dist
    |-index.html
    |-main.js
    |-etc.
  </code></pre>
  
  <p>In the index.html:</p>
  
  <pre><code>&lt;script type="text/javascript" src="main.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>It does not work either when I put the dist folder into the Nest project (and adapt the path).</p>
  
  <h2>I found the solution:</h2>
  
  <p>I use the express module now:</p>
  
  <pre><code>import * as express from 'express';
  ...
  app.use('/', express.static('../client/dist'));
  </code></pre>