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

Error pages not correctly loading CSS #777

simonw opened this issue May 28, 2020 · 4 comments

Error pages not correctly loading CSS #777

simonw opened this issue May 28, 2020 · 4 comments


Copy link

simonw commented May 28, 2020



The HTML starts like this:

<!DOCTYPE html>
    <title>Error 404</title>
    <link rel="stylesheet" href="-/static/app.css?">
@simonw simonw added the bug label May 28, 2020

think, because the given URL of the CSS file doesn't have any complete parameters after query
Try to complete the parameter
<link rel="stylesheet" href="-/static/app.css?(whatever you want that shows a css file)">

@simonw simonw added this to the Datasette 1.0 milestone Jun 6, 2020
Copy link
Owner Author

simonw commented Jun 8, 2020

This is particularly worth fixing now that 403 forbidden pages are much more likely due to #811.

@simonw simonw modified the milestones: Datasette 1.0, Datasette 0.44 Jun 8, 2020
@simonw simonw added the small label Jun 8, 2020
Copy link
Owner Author

simonw commented Jun 9, 2020

Clue: displays correctly but does not.

That's because <link rel="stylesheet" href="-/static/app.css?"> does the correct thing if you are on the root of the site but not if you are in a sub-directory.

Copy link
Owner Author

simonw commented Jun 9, 2020

Here's why:


Lines 1024 to 1029 in 49d6d2f

template = self.ds.jinja_env.select_template(templates)
await asgi_send_html(
send, await template.render_async(info), status=status, headers=headers

404 errors are rendered by looking for a template from ["404.html", "500.html"].

404.html doesn't actually ship with Datasette (plugins or custom template directories can provide it). So the 500.html template is used.

That template extends base.html, which expects there to be base_url and app_css_hash variables. But as you can see in the excerpt above, those variables are not being passed to the template context when the error page is rendered.

@simonw simonw closed this as completed in 647c5ff Jun 9, 2020
simonw added a commit that referenced this issue Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants