Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 page broken when served for URL paths with /s in them #3930

Open
athomas opened this issue Nov 18, 2024 · 5 comments
Open

404 page broken when served for URL paths with /s in them #3930

athomas opened this issue Nov 18, 2024 · 5 comments
Labels
P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@athomas
Copy link
Member

athomas commented Nov 18, 2024

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).
@pq pq added the P2 A bug or feature request we're likely to work on label Nov 20, 2024
@athomas
Copy link
Member Author

athomas commented Nov 25, 2024

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.

@jonasfj
Copy link
Member

jonasfj commented Dec 2, 2024

@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
Copy link
Member Author

athomas commented Dec 2, 2024

@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.

The single file that handles all 404s is currently part of the dartdoc output, though.

@jonasfj
Copy link
Member

jonasfj commented Dec 2, 2024

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.

@athomas
Copy link
Member Author

athomas commented Dec 3, 2024

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.

@srawlins srawlins added the type-enhancement A request for a change that isn't a bug label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants