diff options
| author | Adam Soltys <[email protected]> | 2026-11-16 12:35:03 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-16 12:35:03 -0700 |
| commit | eada69879cee323c6da497fd6cf5899325827c8e (patch) | |
| tree | 46a9958bc1993223f2ea5fbaca7eb7f3204a0cf3 /src/hooks.server.ts | |
| parent | a5ff626228b35ef587f6b9493998184e3e8354fe (diff) | |
| download | coinos-ui-eada69879cee323c6da497fd6cf5899325827c8e.tar.gz coinos-ui-eada69879cee323c6da497fd6cf5899325827c8e.zip | |
Google listed /settings/shopify as "Untitled" instead of the homepage
"When searching for "coinos" on Google right now, the top result points to
https://coinos.io/settings/shopify with the page title "Untitled"" (Oliver,
2026-11-15). Pages render client-side only, so the HTML crawlers get had no
<title>, and the settings layout's redirect for signed-out visitors only ran in
the browser: /settings/shopify answered 200 with an empty shell.
- app.html carries <title>coinos</title> as a fallback; Svelte 5 sets
document.title, so per-page titles still replace it.
- hooks.server.ts sends signed-out GETs under /settings to
/register?redirect=... with a real 307.
- WebSite/Organization JSON-LD tells Google coinos.io is a website, to favour a
normal result over the business-listing card.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/hooks.server.ts')
| -rw-r--r-- | src/hooks.server.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/hooks.server.ts b/src/hooks.server.ts index bd9bbc01..5e0d9e90 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -5,6 +5,21 @@ import type { Handle } from "@sveltejs/kit"; setIpGetter(() => ipStore.getStore()); export const handle: Handle = async ({ event, resolve }) => { + // Pages render client-side only, so the settings layout's login redirect + // never reaches crawlers; Google indexed /settings/shopify as an empty + // "Untitled" page. Redirect signed-out visitors on the server instead. + const { pathname } = event.url; + if ( + event.request.method === "GET" && + !event.cookies.get("token") && + (pathname === "/settings" || pathname.startsWith("/settings/")) && + !event.isDataRequest + ) + return new Response(null, { + status: 307, + headers: { location: `/register?redirect=${pathname}` }, + }); + const ip = event.request.headers.get("cf-connecting-ip") || event.request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() || |
