fix: add new setting item to disable/enable same site property

fixes #55

Signed-off-by: 孙世军 <1083433931@qq.com>
This commit is contained in:
p-sunshijun
2024-12-11 18:08:47 +08:00
parent 9d2d092e9e
commit a8ea35e5c6
4 changed files with 72 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import { type NextRequest } from 'next/server'
import { ChatClient } from 'dify-client'
import { v4 } from 'uuid'
import { API_KEY, API_URL, APP_ID } from '@/config'
import { API_KEY, API_URL, APP_ID, APP_INFO } from '@/config'
const userPrefix = `user_${APP_ID}:`
@ -15,7 +15,10 @@ export const getInfo = (request: NextRequest) => {
}
export const setSession = (sessionId: string) => {
return { 'Set-Cookie': `session_id=${sessionId}` }
if (APP_INFO.disable_session_same_site)
return { 'Set-Cookie': `session_id=${sessionId}; SameSite=None; Secure` }
return { 'Set-Cookie': `session_id=${sessionId}` }
}
export const client = new ChatClient(API_KEY, API_URL || undefined)