I currently have a basic local server set up using Express.
My project consists of an app.js and index.js file for routing purposes.
Within the app.js file, I have all the standard Express configurations, including the line to serve static files:
app.use(express.static(path.join(__dirname, 'public')));
In the index.js file, I have defined the route:
router.get('/', function(req, res) {
res.sendfile('public/staticHTMLfile.html');
});
Inside the public folder, I have my .js and .css files, with proper paths referenced in the static HTML file.
Although when I visit localhost:3000/ in a browser, the HTML loads correctly, the associated js and css files show 404 errors in the npm command prompt:
GET /public/jsFile.js 404 424ms - 1.34kb
GET /public/cssFile.css 404 27ms - 1.34kb
Why aren't they being applied to the HTML? I have checked the script and link tags for accuracy.
If you need more information, please let me know.
Thank you for your assistance.