your personal website on atproto - mirror blento.app

change custom domain stuff

Florian f80b41ce ecea2cbd

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