Skip to content

Commit

Permalink
fix: add new setting item to disable/enable same site property
Browse files Browse the repository at this point in the history
fixes langgenius#55

Signed-off-by: 孙世军 <[email protected]>
  • Loading branch information
p-sunshijun committed Dec 11, 2024
1 parent 9d2d092 commit a8ea35e
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
65 changes: 65 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions app/api/utils/common.ts
Original file line number Diff line number Diff line change
@@ -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}:`

Expand All @@ -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)
1 change: 1 addition & 0 deletions config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const APP_INFO: AppInfo = {
copyright: '',
privacy_policy: '',
default_language: 'en',
disable_session_same_site: false, // set it to true if you want to embed the chatbot in an iframe
}

export const isShowPrompt = false
Expand Down
1 change: 1 addition & 0 deletions types/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export type AppInfo = {
default_language: Locale
copyright?: string
privacy_policy?: string
disable_session_same_site?: boolean
}

export enum Resolution {
Expand Down

0 comments on commit a8ea35e

Please sign in to comment.