The documentation for Express's express.static()
middleware states:
To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express.
It seems that the JS files for dynamic React apps are included, since express.static("some_build_dir")
seems to work even when some_build_dir
is a front-end React app.
However, it seems natural that React apps which use JS to dynamically generate web content should be considered dynamic, rather than static, so there's something I'm missing here.
Q: What kinds of things does Express actually consider "non-static" or "dynamic", then, if even the source files of React apps do not qualify?
Static: Files that the web server (Express) reads from the file system and sends, unmodified, to the client.
Non-static: Responses that are programmatically generated (e.g. from a template with data from a database being inserted into it).
However, it seems natural that React apps which use JS to dynamically generate web content should be considered dynamic, rather than static, so there's something I'm missing here.
As far as the server is concerned, the JS source code and bootstrap HTML file that it sends to the client are static. The dynamic part of them is handled client-side which is outside the server's control.