javascript - Error 404 on static ressources whith parameters on get request -
i'm doing biomedical website node.js , encounter problem: in app.js (server file), have these code
app.get('/disease/:orphanetid', function(req, res) { var orphanetid=req.params.orphanetid; res.render('pages/disease.ejs', {activetitle: "views"}); });
the problem static ressources needed in disease.ejs error 404.
for example code in disease.ejs:
<script src="static/js/domscripts.js"></script>
in chrome console, see:
(red cross) http://localhost:8080/disease/static/js/domscripts.js
the thing is, static ressource @ http://localhost:8080/static/js/domscripts.js, there's string "disease" in url appeared... it's not url!
and after testing stuff, figured out code working:
app.get('/disease', function(req, res) { //var orphanetid=req.params.orphanetid; res.render('pages/disease.ejs', {activetitle: "views"}); });
so if don't have parameter, it's working, need it.
for info, code for static ressources is:
app.use('/static', express.static(__dirname + '/public'));
what should have parameter?
change script path:
<script src="/static/js/domscripts.js"></script>
Comments
Post a Comment