A node.js web server does not serve ANY files by default. So, just because you have a route that serves index.html
, that does not mean that any other file is served by node.js. node.js is not like other web servers that think of themselves first as file serving processes and second as app servers. node.js gives you full control and it serves no files by default. If you want it to serve a directory of static files (such as script files), then one single app.use(express.static(...))
line of code will cause it to serve all the files in a particular directory.
If you're asking why the same static route that serves index.html does not serve the other two files, then that would simply be a case of the paths and file locations not lining up to be found appropriately. Since you haven't really given us the full detail on your file system structure or path structure, we can't offer exact specifics on what you should change.
If system.js and config.js are in the same directory as index.html, then you should remove the path from in front of their script tags. If they are not in the same directory, then you may need another app.use(express.static(...))
that covers the other path/directory combination.
Does every resource index.html uses really have to be served
statically through app.use()?
No it does not if it is in the same location as index.html and is referred to by the same path and if you're using an express.static()
that covers that whole directory.
Every resource you want the node.js server to send out must be specifically covered by some route in your server. Some routes may cover many files or an entire directory of files, but every request you want to work must be covered by a route.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…