Note that there are some explanatory texts on larger screens.

plurals
  1. PONode.js static file server logic (using Connect middleware)
    primarykey
    data
    text
    <p>Let's say I have the following filesystem structure:</p> <pre class="lang-none prettyprint-override"><code>/app/ Main application folder /app.js Server JS file ran by node.js /public Folder containing files for public website (port 80) /index.html /js/ /game.js /admin/ Folder containing files used by local network system (port X) /index.html /js/ /screen.js /share/ Folder containing files to be used by public website OR lan /js/ /jquery.js </code></pre> <p>The end result is that <code>admin/index.html</code> would look like:</p> <pre class="lang-html prettyprint-override"><code>&lt;script type="text/javascript" src="/js/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/js/screen.js"&gt;&lt;/script&gt; </code></pre> <p>That is, I'm loading two files from different locations. Basically, the thought here is <em>"check if file is in <code>/share</code>, if not, try loading it from folder according to port"</em>.</p> <p>And here's the current code I'm using:</p> <pre class="lang-js prettyprint-override"><code>var connect = require('connect'), sourcePublic = connect().use( connect.static(__dirname + '/public', { maxAge: 86400000 }) ), sourceAdmin = connect().use( connect.static(__dirname + '/admin', { maxAge: 86400000 }) ), sourceShare = connect().use( connect.static(__dirname + '/share', { maxAge: 86400000 }) ), serverPublic = http.createServer(sourcePublic).listen(80), serverAdmin = http.createServer(sourceAdmin).listen(90); // ok, how do I use sourceShare? </code></pre> <p><strong>PS:</strong> This system should be world-accessible through <code>http://host/</code> (possibly a domain or static ip) AND accessible via the local network through <code>http://host:90/</code>.</p> <p>While the stuff on port 90 won't damage the system (it's just an output screen), I'd rather if people would not be able to access it from outside (easily done by ensuring there is no port 90 forwarding between router and server).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload