coyotte508 HF staff commited on
Commit
41b9769
1 Parent(s): 67867a9

🔧 Change cookie name

Browse files
Files changed (2) hide show
  1. .env +1 -0
  2. src/hooks.server.ts +3 -2
.env CHANGED
@@ -5,6 +5,7 @@ MONGODB_URL=#your mongodb URL here
5
  MONGODB_DB_NAME=chat-ui
6
  HF_TOKEN=#your huggingface token here
7
  SHARE_BASE_URL=#https://hf.co/chat
 
8
 
9
  PUBLIC_MODEL_ENDPOINT=https://api-inference.huggingface.co/models/OpenAssistant/oasst-sft-1-pythia-12b
10
  PUBLIC_MODEL_NAME=OpenAssistant/oasst-sft-1-pythia-12b
 
5
  MONGODB_DB_NAME=chat-ui
6
  HF_TOKEN=#your huggingface token here
7
  SHARE_BASE_URL=#https://hf.co/chat
8
+ COOKIE_NAME=hf-chat
9
 
10
  PUBLIC_MODEL_ENDPOINT=https://api-inference.huggingface.co/models/OpenAssistant/oasst-sft-1-pythia-12b
11
  PUBLIC_MODEL_NAME=OpenAssistant/oasst-sft-1-pythia-12b
src/hooks.server.ts CHANGED
@@ -1,13 +1,14 @@
 
1
  import type { Handle } from '@sveltejs/kit';
2
  import { addYears } from 'date-fns';
3
 
4
  export const handle: Handle = async ({ event, resolve }) => {
5
- const token = event.cookies.get('session');
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,
 
1
+ import { COOKIE_NAME } from '$env/static/private';
2
  import type { Handle } from '@sveltejs/kit';
3
  import { addYears } from 'date-fns';
4
 
5
  export const handle: Handle = async ({ event, resolve }) => {
6
+ const token = event.cookies.get(COOKIE_NAME);
7
 
8
  event.locals.sessionId = token || crypto.randomUUID();
9
 
10
  // Refresh cookie expiration date
11
+ event.cookies.set(COOKIE_NAME, event.locals.sessionId, {
12
  path: '/',
13
  sameSite: 'lax',
14
  secure: true,