title: Trying to clone a repository & send it to the frontend with Node & Express
body: <p>I'm trying to serve a given, clone repository using NodeJS &amp; ExpressJS. I was able to clone it locally, but I am not able to send it to the frontend. This is my code:</p>
  <pre class="lang-js prettyprint-override"><code>const express = require(&quot;express&quot;);
  const app = express();
  const port = 3000;
  const path = require(&quot;path&quot;);
  const { execSync } = require(&quot;child_process&quot;);
  
  // function to download the repo
  const downloadRepo = (repoURL) =&gt;
    execSync(`git clone ${repoURL}`, {
      stdio: [0, 1, 2],
      cwd: path.resolve(__dirname, &quot;&quot;),
    });
  
  // route to clone the repo
  app.get(&quot;/:repoOwner/:repoName&quot;, async (req, res) =&gt; {
    const { repoOwner, repoName } = req.params;
  
    // composing the repo URL to be downloaded
    const fullRepoURL = `https://github.com/${repoOwner}/${repoName}.git`;
  
    // downloading the repo in the root folder
    await downloadRepo(fullRepoURL);
  
    // returns the FULL URL of the repo in the frontend
    res.send(fullRepoURL);
  
    // trying to return the repo's content in the the frontend
    // I get status 304 (not modified)
    res.sendFile(path.resolve(__dirname, repoName));
  });
  
  app.listen(port, () =&gt; {
    console.log(`App listening at http://localhost:${port}`);
  });
  </code></pre>