diff --git a/server-rs/src/og_middleware.rs b/server-rs/src/og_middleware.rs index 89d6ba8..922bbb9 100644 --- a/server-rs/src/og_middleware.rs +++ b/server-rs/src/og_middleware.rs @@ -22,7 +22,7 @@ pub async fn og_middleware(request: Request, next: Next) -> Response { let response = next.run(request).await; // Only inject OG tags into SPA HTML responses, not proxied PocketBase responses - if path.starts_with("/pb/") || path.starts_with("/api/") { + if path.starts_with("/pb/") || path.starts_with("/api/") || path.starts_with("/s/") { return response; } diff --git a/server-rs/src/routes/shorten.rs b/server-rs/src/routes/shorten.rs index 8c7d123..0fb8f05 100644 --- a/server-rs/src/routes/shorten.rs +++ b/server-rs/src/routes/shorten.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use axum::extract::{Path, State}; -use axum::http::StatusCode; -use axum::response::{IntoResponse, Redirect, Response}; +use axum::http::{header, StatusCode}; +use axum::response::{Html, IntoResponse, Response}; use axum::Json; use rand::Rng; use serde::{Deserialize, Serialize}; @@ -139,7 +139,38 @@ pub async fn get_short_url( match params { Some(params) => { - Redirect::temporary(&format!("/dashboard?{params}")).into_response() + let redirect_url = format!("/dashboard?{params}"); + let og_image_url = format!( + "{}/api/screenshot?og=1&{params}", + state.public_url + ); + let og_url = format!("{}/s/{code}", state.public_url); + let og_title = "Perfect Postcode \u{2014} Every neighbourhood in England"; + let og_description = "Explore property prices, energy ratings, crime stats, school ratings, and more across England on one interactive map."; + + let html = format!( + r#" + + + + + + + + + + + + + +{og_title} +"# + ); + ( + [(header::CACHE_CONTROL, "public, max-age=86400")], + Html(html), + ) + .into_response() } None => StatusCode::NOT_FOUND.into_response(), }