main: Serve static files from /static path
Static files served with FileServer have a low priority : all other possible routes a this root will be checked first, before they get returned. As we have a lot of routes at the root, they will be hit a lot before we get to the static files. Move the static files to a dedicated path to reduce those internal redirections, update the paths in the HTML and add one for the favicon so it continues to work.
This commit is contained in:
parent
222acbb4f8
commit
36b2e61e26
2 changed files with 5 additions and 4 deletions
|
@ -35,7 +35,7 @@ async fn index(mut db: Connection<Db>) -> Redirect {
|
||||||
#[launch]
|
#[launch]
|
||||||
fn rocket() -> _ {
|
fn rocket() -> _ {
|
||||||
rocket::build()
|
rocket::build()
|
||||||
.mount("/", FileServer::from(relative!("static_files")))
|
.mount("/static/", FileServer::from(relative!("static_files")))
|
||||||
.attach(auth::stage())
|
.attach(auth::stage())
|
||||||
.attach(week::stage())
|
.attach(week::stage())
|
||||||
.attach(truth::stage())
|
.attach(truth::stage())
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{{ title }}</title>
|
<title>{{ title }}</title>
|
||||||
<link href="/style.css" rel="stylesheet"/>
|
<link href="/static/style.css" rel="stylesheet"/>
|
||||||
|
<link href="/static/favicon.ico" rel="icon"/>
|
||||||
{% if user.logged_in == true and not user.is_admin %}
|
{% if user.logged_in == true and not user.is_admin %}
|
||||||
<script defer="defer" type="text/javascript" src="/vote_handler.js"></script>
|
<script defer="defer" type="text/javascript" src="/static/vote_handler.js"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script defer="defer" type="application/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@4.4.3/dist/chart.umd.min.js"></script>
|
<script defer="defer" type="application/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@4.4.3/dist/chart.umd.min.js"></script>
|
||||||
<script defer="defer" type="text/javascript" src="/vote_chart.js"></script>
|
<script defer="defer" type="text/javascript" src="/static/vote_chart.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
{#{% import "week_change_arrows" as week_macro %}#}
|
{#{% import "week_change_arrows" as week_macro %}#}
|
||||||
|
|
Loading…
Add table
Reference in a new issue