-
-
Notifications
You must be signed in to change notification settings - Fork 263
Description
When SystemJS is misconfigured and it tries to fetch modules via URLs that don't map to js files, lite-server redirects the requests to index.html (or /) in order to support the window.history.pushState location strategy.
The problem with this is that System will typically error with a weird error like Uncaught SyntaxError: Unexpected token <. This error is very difficult to understand and fix.
It would be much better if lite-server error with 404s in this case, giving the developer the correct feedback that the file is not present at this url. This should be achieved without breaking the pushState support for location by distinguishing the SystemJS requests from the application requests. SystemJS makes all requests with Accept: application/x-es-module, */* request header and we can use this to identify these requests and treat them differently from others.
This kind of treatment of different requests might be useful for other kinds of errors in general (e.g. image fetches). So it might actually be better to change the server to rewrite only requests with request header Accept:text/html,application/xhtml+xml,... which is typically used by the browser to fetch the initial html (which is the only thing we want to rewrite).

