Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import tailwindcss from "@tailwindcss/vite";
// Server output so our /api routes run as Vercel serverless functions.
// All daily.dev calls go through them, keeping the token off the client.
export default defineConfig({
// Canonical production URL — used as a fallback when building absolute OG/
// canonical URLs (behind Vercel's proxy the request host can read as localhost).
site: "https://daily-dev-roulette.vercel.app",
output: "server",
adapter: vercel({
// Inject the Vercel Web Analytics script in production.
Expand Down
13 changes: 10 additions & 3 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ const {
profile = null,
} = Astro.props;

// Absolute URLs resolved at request time, so OG works on any deploy domain.
const canonical = new URL(Astro.url.pathname, Astro.url.origin).href;
const ogImage = new URL("/og-image.png", Astro.url.origin).href;
// Absolute URLs for OG/canonical. Behind Vercel's proxy Astro.url.origin reads
// as "localhost", which breaks link previews, so prefer the forwarded host
// headers and fall back to the configured `site` (then Astro.url.origin).
const forwardedHost = Astro.request.headers.get("x-forwarded-host");
const forwardedProto = Astro.request.headers.get("x-forwarded-proto") ?? "https";
const origin = forwardedHost
? `${forwardedProto}://${forwardedHost}`
: (Astro.site?.origin ?? Astro.url.origin);
Comment on lines +20 to +24
const canonical = new URL(Astro.url.pathname, origin).href;
const ogImage = new URL("/og-image.png", origin).href;
---

<!doctype html>
Expand Down