File not found - http://localhost/path-file-script

2019-07-18 10:41发布

问题:

When I visit my node application running on my raspberry pi at 10.0.my.ip.address the app loads but get 404 multiple files not found. The src to my files, scripts and images look similar to this

<link rel="stylesheet" href="http://localhost/Ziroid_Functions/Clovis_App/public/clovisapp.css">

<img src="http://localhost/Ziroid_Functions/Clovis_App/public/img/doubleUp.png" alt="Smiley face" >

<script type="text/javascript" src="http://localhost/Ziroid_Functions/Clovis_App/public/js/radar.js"></script>

Whats weird is that these lines on code worked yesterday. I added a few more src links which got errors. I restarted my apache server on desktop top then all the sudden my desktop started getting errors with all src links being localhost/some-address.

I tried loading application on my other computer and all the scirpts,images and links load fine.

What might the problem be and how do I fix this?

回答1:

Ok I resolved this issue simply by removing localhost from src and using express static files to render files from my public folder