I use express that returns me some html page:
app.get('/', function(req, res){
return res.sendFile(path.resolve(__dirname + '/views/index.html'));
});
That index.html contains a bunch of scripts in the tag <script></script>.
I would like to move it to an external file like this:
<script src="./indexScripts.js"></script>
However it doesn't work and returns the following errors:
GET http://.../indexScripts.js net::ERR_ABORTED
GET http://.../indexScripts.js 404 (Not Found)
Would you have any clue on what I should do?
A solution I found is exposing the script:
app.get('/scripts', function(req, res){
return res.sendFile(path.resolve(__dirname + '/views/indexScripts.js'));
});
... then using it:
<script src="scripts"></script>
But it really seems not the correct way of handling this / prone to security breach...
Thank you