diff --git a/src/assets.rs b/src/assets.rs index c917fb5..476c5c9 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -9,10 +9,14 @@ static ERROR_PAGES: Dir = include_dir!("$CARGO_MANIFEST_DIR/web/build/prerendere pub async fn serve_embedded_asset(uri: Uri) -> Response { let path = uri.path(); + serve_asset_by_path(path) +} +/// Serve an embedded asset by path, or return None if not found +pub fn try_serve_embedded_asset(path: &str) -> Option { let asset_path = path.strip_prefix('/').unwrap_or(path); - if let Some(file) = CLIENT_ASSETS.get_file(asset_path) { + CLIENT_ASSETS.get_file(asset_path).map(|file| { let mime_type = mime_guess::from_path(asset_path) .first_or_octet_stream() .as_ref() @@ -39,6 +43,12 @@ pub async fn serve_embedded_asset(uri: Uri) -> Response { } (StatusCode::OK, headers, file.contents()).into_response() + }) +} + +fn serve_asset_by_path(path: &str) -> Response { + if let Some(response) = try_serve_embedded_asset(path) { + response } else { tracing::debug!(path, "Embedded asset not found"); (StatusCode::NOT_FOUND, "Asset not found").into_response() diff --git a/src/main.rs b/src/main.rs index 3ca90f8..db177e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ mod middleware; mod og; mod r2; mod tarpit; -use assets::serve_embedded_asset; +use assets::{serve_embedded_asset, try_serve_embedded_asset}; use config::{Args, ListenAddr}; use formatter::{CustomJsonFormatter, CustomPrettyFormatter}; use health::HealthChecker; @@ -1235,6 +1235,15 @@ async fn isr_handler(State(state): State>, req: Request) -> Respon return (StatusCode::NOT_FOUND, "Not found").into_response(); } + // Check if this is a static asset that exists in embedded CLIENT_ASSETS + // This handles root-level files like favicon.ico, favicon.svg, etc. + if is_static_asset(path) { + if let Some(response) = try_serve_embedded_asset(path) { + return response; + } + // If not found in embedded assets, continue to proxy (might be in Bun's static dir) + } + let bun_url = if state.downstream_url.starts_with('/') || state.downstream_url.starts_with("./") { if query.is_empty() { diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte index 155bd47..6183bc6 100644 --- a/web/src/routes/+layout.svelte +++ b/web/src/routes/+layout.svelte @@ -35,7 +35,9 @@ - + + + {metadata.title} diff --git a/web/static/apple-touch-icon-180.png b/web/static/apple-touch-icon-180.png new file mode 100644 index 0000000..1ec584a Binary files /dev/null and b/web/static/apple-touch-icon-180.png differ diff --git a/web/static/apple-touch-icon.png b/web/static/apple-touch-icon.png new file mode 100644 index 0000000..468b809 Binary files /dev/null and b/web/static/apple-touch-icon.png differ diff --git a/web/static/favicon-192.png b/web/static/favicon-192.png new file mode 100644 index 0000000..30a6af0 Binary files /dev/null and b/web/static/favicon-192.png differ diff --git a/web/static/favicon.ico b/web/static/favicon.ico new file mode 100644 index 0000000..0768a9a Binary files /dev/null and b/web/static/favicon.ico differ diff --git a/web/static/favicon.svg b/web/static/favicon.svg new file mode 100644 index 0000000..ebd3a14 --- /dev/null +++ b/web/static/favicon.svg @@ -0,0 +1 @@ + \ No newline at end of file