your personal website on atproto - mirror blento.app

Merge pull request #143 from flo-bit/custom-domains-editing

fix client id

authored by Florian and committed by GitHub 62380835 c1fcf4a6

+18 -6
+11 -4
src/lib/atproto/auth.svelte.ts
··· 37 37 did: undefined as Did | undefined 38 38 }); 39 39 40 - export async function initClient() { 40 + export async function initClient(options?: { customDomain?: string }) { 41 41 user.isInitializing = true; 42 42 43 - const clientId = dev 43 + const client_id = dev 44 44 ? `http://localhost` + 45 45 `?redirect_uri=${encodeURIComponent('http://127.0.0.1:5179' + REDIRECT_PATH)}` + 46 46 `&scope=${encodeURIComponent(metadata.scope)}` ··· 53 53 } 54 54 }); 55 55 56 + const redirect_uri = dev ? 'http://127.0.0.1:5179' + REDIRECT_PATH : metadata.redirect_uris[0]; 57 + 58 + if (options?.customDomain) { 59 + client_id.replace('blento.app', options.customDomain); 60 + redirect_uri.replace('blento.app', options.customDomain); 61 + } 62 + 56 63 configureOAuth({ 57 64 metadata: { 58 - client_id: clientId, 59 - redirect_uri: dev ? 'http://127.0.0.1:5179' + REDIRECT_PATH : metadata.redirect_uris[0] 65 + client_id, 66 + redirect_uri 60 67 }, 61 68 identityResolver: new LocalActorResolver({ 62 69 handleResolver: handleResolver,
+5
src/routes/+layout.server.ts
··· 1 + export async function load({ platform, request }) { 2 + const customDomain = request.headers.get('X-Custom-Domain')?.toLocaleLowerCase(); 3 + 4 + return { customDomain }; 5 + }
+2 -2
src/routes/+layout.svelte
··· 9 9 import { goto } from '$app/navigation'; 10 10 import LoginModal from '$lib/atproto/UI/LoginModal.svelte'; 11 11 12 - let { children } = $props(); 12 + let { children, data } = $props(); 13 13 14 14 const errorMessages: Record<string, (params: URLSearchParams) => string> = { 15 15 handle_not_found: (p) => `Handle ${p.get('handle') ?? ''} not found!` 16 16 }; 17 17 18 18 onMount(() => { 19 - initClient(); 19 + initClient({ customDomain: data.customDomain }); 20 20 21 21 const error = page.url.searchParams.get('error'); 22 22 if (error) {