Lets say I am serving the following index.html
file which is in the root directory via an express
server.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<h1>Hello</h1>
<script src="/public/system.js"></script>
<script src="/public/config.js"></script>
<script>System.import("app/main")</script>
</body>
</html>
Both system.js
and config.js
are in the public directory folder.
To get index.html
to load these files I must include the following line in my app.js
file so the requests can be searched in the public folder:
app.use(express.static(path.join(config.root, 'public')));
Why is this so? Why can't index.html
correctly reference the files without the above line since the src
path to the resources is correct? Same goes for app/main
. Does every resource index.html uses really have to be served statically through app.use()
?