node.js - NPM package 'http-server' seems to 404 arbitrary asset paths -
i have simple folder want serve localhost bunch of static assets. file structure looks this:
- build
- assets
- data
- images
- index.html
i installed http-server via npm using npm install http-server -g , i'm serving directory (build) full of static files localhost using:
cd ~/myproject/build http-server . the result can visit localhost:8080 in browser , index.html loading expected. however, loads incompletely, , in console see js file (in /assets path) referenced in index.html is loading , running correctly, http-server returning 404 relative path assets in /data path. in other words, following browser console error:
get http://localhost:8080/data/myfile.json 404 (not found) attempting reach asset direct path fails, e.g. typing in browser address bar:
http://localhost:8080/data/myfile.json however, if move asset /images path (just experiment) works. in other words, following in browser address bar return desired file:
http://localhost:8080/images/myfile.json also tested installing expressjs in project, , creating simple nodejs script configured serve 'build' directory (same physical directory no file structure or naming alterations). worked no path or filename alterations, know file structure , names good. fishy http-server. in meantime, i'm using expressjs solution, fine, i'm curious problem in http-server because it's handy solution future if can working!
why can http-server find index.html , /assets path, not /data path? /data path illegal or have done wrong? there configuration can alter in http-server make feasible? can't rename /data path because unalterable minified vendor js refers path.
Comments
Post a Comment