You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #1611, we added API allowing app developers to serve static assets from their applications. To merge the pull request sooner, we have intentionally accepted a design with suboptimal performance:
All serve-static middleware is mounted before API routes, violating the best practices.
Users are forbidden to mount static content at root / to avoid the biggest performance penalty.
Let's rethink the way how static files are served, follow the best practices and get the best performance.
In #1611 (comment) and #1784, I proposed the following solution for consideration:
Can we define a special kind of a catch-all route that will:
match any URL that did not match any API endpoint; i.e. the sequence action findRoute returns this catch-all route if no API endpoint matched the requested URL
run the express Router where static assets were mounted; i.e. the sequence action invoke runs express routing to handle static assets
throw HttpError.NotFound when no static asset was found, i.e. the sequence action invoke throws the 404 error or the express Router for static assets called next().
In my mind, such solution would solve most if not all issues:
static middleware is invoked after any routes
static middleware is invoked as part of the sequence
In #1611, we added API allowing app developers to serve static assets from their applications. To merge the pull request sooner, we have intentionally accepted a design with suboptimal performance:
/
to avoid the biggest performance penalty.Let's rethink the way how static files are served, follow the best practices and get the best performance.
See also #559
Acceptance criteria
serve-static
middleware is invoked only after no other route (an API endpoint, an Express-like route) matched the request/
The text was updated successfully, but these errors were encountered: