your personal website on atproto - mirror blento.app

Merge pull request #137 from flo-bit/custom-domains

change custom domain stuff

authored by

Florian and committed by
GitHub
dddc492c 3de7b3b1

+9 -11
+5 -6
src/routes/+page.server.ts
··· 1 1 import { loadData } from '$lib/website/load'; 2 2 import { env } from '$env/dynamic/public'; 3 3 import type { UserCache } from '$lib/types'; 4 - import type { ActorIdentifier, Handle } from '@atcute/lexicons'; 5 - 6 - export async function load({ platform, url }) { 7 - const hostname = url.hostname; 4 + import type { ActorIdentifier } from '@atcute/lexicons'; 8 5 6 + export async function load({ platform, request }) { 9 7 const handle = env.PUBLIC_HANDLE; 10 8 11 9 const kv = platform?.env?.CUSTOM_DOMAINS; 12 10 13 11 const cache = platform?.env?.USER_DATA_CACHE as unknown; 12 + const customDomain = request.headers.get('X-Custom-Domain')?.toLocaleLowerCase(); 14 13 15 - if (kv) { 14 + if (kv && customDomain) { 16 15 try { 17 - const did = await kv.get(hostname); 16 + const did = await kv.get(customDomain); 18 17 19 18 if (did) return await loadData(did as ActorIdentifier, cache as UserCache); 20 19 } catch (error) {
+4 -5
src/routes/edit/+page.server.ts
··· 3 3 import type { UserCache } from '$lib/types'; 4 4 import type { ActorIdentifier } from '@atcute/lexicons'; 5 5 6 - export async function load({ url, platform }) { 7 - const hostname = url.hostname; 8 - 6 + export async function load({ platform, request }) { 9 7 const handle = env.PUBLIC_HANDLE; 10 8 11 9 const kv = platform?.env?.CUSTOM_DOMAINS; 12 10 13 11 const cache = platform?.env?.USER_DATA_CACHE as unknown; 12 + const customDomain = request.headers.get('X-Custom-Domain')?.toLocaleLowerCase(); 14 13 15 - if (kv) { 14 + if (kv && customDomain) { 16 15 try { 17 - const did = await kv.get(hostname); 16 + const did = await kv.get(customDomain); 18 17 19 18 if (did) return await loadData(did as ActorIdentifier, cache as UserCache); 20 19 } catch (error) {