-
Notifications
You must be signed in to change notification settings - Fork 45
isSSR
should not render as template if the request implies a non-html MIME type
#116
Comments
Need to come up with potential solutions. |
Permutations that work today
pros: it's what we have today Covered cases: 8/16 Proposed solutions so far and what scenarios they fixextension regex check
pros: covers all classes of use cases (ssr, dynamic asset, static asset, endpoint) Covered cases: 12/16 extension convention (no-extension = ssr, extension = non-ssr) in addition to accepts header heuristicspros: same as extension regex check Covered cases: 12/16 asset manifest check
pros: addresses any type of static assets Covered cases: 10/16 unset ctx.element and ctx.template if ctx.body is setpros: addresses all cases Covered cases: 16/16 but poorly Other concernsIt may also be desirable to show user-friendly 404s for a non-existing route, regardless of whether it would have been ssr'ed via other heuristics. This requires the ability to arbitrarily override the isSSR check, and could conceivably be supported via DI app.register(IsSSRToken, ctx => !ctx.path.match(/paths|with|no|ssr/)) pros: addresses all cases Covered cases: 16/16 Analysis
Recommendation
|
There's something I find really appealing about a solution using a path-prefix, (e.g. a route is SSR if and only if it does not start with I'm less enthused about an extension-based convention, since there's more ambiguity in the case of |
@rtsao I think prefix doesn't conform web ideology. URL doesn't imply type, headers do. It also means that routes with Example: I have an application which is more or less file browser (think about s3 file browser). And I want to show file path as URL path, like Take a look at this comment #45 (comment), maybe it could be a better way. |
We have implemented both parts 1) and 2) of your suggestion. I think we'll still need to iterate on this to make it nicer for entries in the asset manifest, and also potentially per-plugin setting of headers. People should generally be unblocked now, and we can continue making this better over time. |
Currently, there's no good way of rendering a dynamic PDF other than doing horrible hacks.
We already do the right thing for the
.js
extension:fusion-core/src/plugins/ssr.js
Line 61 in fd40195
This logic should be extended to other MIME types, such as PDF, images, fonts, etc
The text was updated successfully, but these errors were encountered: