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
1
import { loadData } from '$lib/website/load';
2
2
import { env } from '$env/dynamic/public';
3
3
import type { UserCache } from '$lib/types';
4
4
-
import type { ActorIdentifier, Handle } from '@atcute/lexicons';
5
5
-
6
6
-
export async function load({ platform, url }) {
7
7
-
const hostname = url.hostname;
4
4
+
import type { ActorIdentifier } from '@atcute/lexicons';
8
5
6
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
12
+
const customDomain = request.headers.get('X-Custom-Domain')?.toLocaleLowerCase();
14
13
15
15
-
if (kv) {
14
14
+
if (kv && customDomain) {
16
15
try {
17
17
-
const did = await kv.get(hostname);
16
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
6
-
export async function load({ url, platform }) {
7
7
-
const hostname = url.hostname;
8
8
-
6
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
12
+
const customDomain = request.headers.get('X-Custom-Domain')?.toLocaleLowerCase();
14
13
15
15
-
if (kv) {
14
14
+
if (kv && customDomain) {
16
15
try {
17
17
-
const did = await kv.get(hostname);
16
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) {