title: How to prevent direct access to file in Node but allow server to load file?
body: <p>I have multiple dynamic directories that I want to prevent the user from accessing, but I'd like the server to load those files.</p>
  
  <p>My structure is as follows but does grow dynamically so I can't statistically name the files:</p>
  
  <ul>
  <li>views/mods/headers/john/</li>
  <li>views/mods/headers/john/meta/screenshot.png</li>
  <li>views/mods/headers/john/index.html</li>
  <li>views/mods/headers/john/style.css</li>
  </ul>
  
  <p>How do I provide access to the <code>folder john</code> for the server and not a user trying to view it directly?, as well as <code>screenshot.png, index.html and style.css</code>?</p>
  
  <p>Fairly new to Node so I'm not that sure, but in .htaccess it would be something like this: <a href="https://stackoverflow.com/questions/10236717/htaccess-how-to-prevent-a-file-from-direct-url-access">(htaccess) How to prevent a file from DIRECT URL ACCESS?</a></p>
  
  <p>Thanks.</p>