Spaces:
Sleeping
Sleeping
Commit
•
3ddb8c6
1
Parent(s):
c3aa4e3
🩹 Fix proxified headers + remove guard in hook (#27)
Browse files
src/hooks.server.ts
CHANGED
@@ -6,17 +6,14 @@ export const handle: Handle = async ({ event, resolve }) => {
|
|
6 |
|
7 |
event.locals.sessionId = token || crypto.randomUUID();
|
8 |
|
9 |
-
//
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
expires: addYears(new Date(), 1)
|
18 |
-
});
|
19 |
-
}
|
20 |
|
21 |
const response = await resolve(event);
|
22 |
|
|
|
6 |
|
7 |
event.locals.sessionId = token || crypto.randomUUID();
|
8 |
|
9 |
+
// Refresh cookie expiration date
|
10 |
+
event.cookies.set('session', event.locals.sessionId, {
|
11 |
+
path: '/',
|
12 |
+
sameSite: 'lax',
|
13 |
+
secure: true,
|
14 |
+
httpOnly: true,
|
15 |
+
expires: addYears(new Date(), 1)
|
16 |
+
});
|
|
|
|
|
|
|
17 |
|
18 |
const response = await resolve(event);
|
19 |
|
src/routes/api/conversation/+server.ts
CHANGED
@@ -2,13 +2,18 @@ import { HF_TOKEN } from '$env/static/private';
|
|
2 |
import { PUBLIC_MODEL_ENDPOINT } from '$env/static/public';
|
3 |
|
4 |
export async function POST({ request, fetch }) {
|
5 |
-
|
6 |
headers: {
|
7 |
-
|
8 |
-
'Content-Type': 'application/json',
|
9 |
Authorization: `Basic ${HF_TOKEN}`
|
10 |
},
|
11 |
method: 'POST',
|
12 |
body: await request.text()
|
13 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
|
|
2 |
import { PUBLIC_MODEL_ENDPOINT } from '$env/static/public';
|
3 |
|
4 |
export async function POST({ request, fetch }) {
|
5 |
+
const resp = await fetch(PUBLIC_MODEL_ENDPOINT, {
|
6 |
headers: {
|
7 |
+
'Content-Type': request.headers.get('Content-Type') ?? 'application/json',
|
|
|
8 |
Authorization: `Basic ${HF_TOKEN}`
|
9 |
},
|
10 |
method: 'POST',
|
11 |
body: await request.text()
|
12 |
});
|
13 |
+
|
14 |
+
return new Response(resp.body, {
|
15 |
+
headers: Object.fromEntries(resp.headers.entries()),
|
16 |
+
status: resp.status,
|
17 |
+
statusText: resp.statusText
|
18 |
+
});
|
19 |
}
|