tangled
alpha
login
or
join now
flo-bit.dev
/
blento
21
fork
atom
your personal website on atproto - mirror
blento.app
21
fork
atom
overview
issues
pulls
pipelines
change custom domain stuff
Florian
1 month ago
f80b41ce
ecea2cbd
+9
-11
2 changed files
expand all
collapse all
unified
split
src
routes
+page.server.ts
edit
+page.server.ts
+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
0
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;
0
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';
0
0
0
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;
0
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 }) {
0
0
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) {