404 page broken when served for URL paths with `/`s in them
The 404 page can't load files that it depends on when it's not served at the same path as static-assets/ (the path contains a slash after the root of the page).
Example: https://api.dart.dev/dart-core/dart-cor2-library.html (wrong styling, broken links to other dartdoc pages) https://api.dart.dev/wrong (works as expected)
Background:
The load balancer of api.dart.dev (or currently the GCS bucket) serve the 404 page as part of the 404 response of the given URL (no redirect). However, the page's implementation assumes it's served relative to its static-assets/ (which is only available at the root).
Possible solutions:
- The page is rewritten to not depend on its location.
- The load balancer could intercept requests for
**/static-assets/**and redirect them to the root (hackish as the page shouldn't depend on load balancer rules to work, would fix the styling but might need additional redirects to make the page fully functional).
Another possible solution (via @jonasfj):
- Have a simple 404 page that redirects to the proper 404 page with javascript which then gets served from the expected location.
@athomas I think this is specific to api.dart.dev, not something that needs to be done in dartdoc.
Since the GCS serving setup for api.dart.dev basically has a single file that handles all 404s, I'd suggest we just hand write a not-found.htm for this purpose.
@athomas I think this is specific to
api.dart.dev, not something that needs to be done indartdoc.Since the GCS serving setup for
api.dart.devbasically has a single file that handles all 404s, I'd suggest we just hand write anot-found.htmfor this purpose.
The single file that handles all 404s is currently part of the dartdoc output, though.
The single file that handles all 404s is currently part of the dartdoc output, though.
Yeah, but your bucket contains output from any different versions of dartdoc. And many different SDK versions.
And the layout of your bucket is something you've decided.
You could just make an HTML file as follows:
<meta http-equiv="refresh" content="0; url=https://api.dart.dev/__404error.html">
<h1>404 - Not Found</h1>
The downside is that now I can't really fix the typo I made. Because the URL I mistyped has disappeared from the address bar.
The single file that handles all 404s is currently part of the dartdoc output, though.
Yeah, but your bucket contains output from any different versions of
dartdoc. And many different SDK versions.And the layout of your bucket is something you've decided.
The problem occurs regardless of that, because even if you host dartdoc from the root of your site, the 404 page will still be broken depending on how many slashes the 404 URL has.
That being said, my specific problem can be solved with a solution specific to api.dart.dev.