title: Express.js: Set cache-control header for static assets bundled in webpack
body: <p>I can't figure out how to set a Cache-Control header for static assets using express.js and webpack.</p>
  
  <p>In my react app I'm including static images as follows:</p>
  
  <pre><code> &lt;img src={require("./images/Logo.png")} alt="Logo"/&gt;
  </code></pre>
  
  <p>I have a loader in my webpack.config.js that outputs images to /public/images</p>
  
  <pre><code>module: {
      loaders: [
      {
          test: /\.png/,
          loader: 'url-loader?limit=10000&amp;name=public/images/[name].[ext]'
       }]
  }
  </code></pre>
  
  <p>Finally, I mark the /public folder in server.js as containing static assets and set the Cache-Control header</p>
  
  <pre><code>const server = express();
  server.use(express.static(path.join(__dirname, 'public'), {maxAge: "30d"}));
  </code></pre>
  
  <p>The problem is that <code>require()</code> resolves the path including /public folder:</p>
  
  <pre><code>&lt;img class="full-width" src="/public/images/Logo.png" alt="Logo"&gt;
  </code></pre>
  
  <p>but <code>express</code> expects a URL without the <code>public/</code> part.</p>
  
  <p>Is there a way to force <code>express.static()</code> to include the <code>/public</code> in its path?</p>