Skip to content

Commit a48043f

Browse files
committed
fix(docs): allow blog assistant CORS
1 parent cf0b388 commit a48043f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

functions/api/docs-chat.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ type ChatRequestBody = {
2727

2828
const DEFAULT_MODEL = 'gemini-flash-lite-latest'
2929
const DEFAULT_MAX_TOKENS = 1200
30+
const DEFAULT_CORS_ORIGINS = [
31+
'https://notionnext.tangly1024.com',
32+
'https://blog.tangly1024.com'
33+
]
3034
const MAX_REQUEST_BYTES = 20_000
3135
const MAX_MESSAGES = 6
3236
const MAX_USER_TEXT_CHARS = 1000
@@ -72,9 +76,10 @@ const json = (body: unknown, init: ResponseInit = {}) =>
7276

7377
const corsHeaders = (request: Request, env: Env) => {
7478
const origin = request.headers.get('origin')
75-
const allowed = env.DOCS_CHAT_CORS_ORIGINS?.split(',')
76-
.map(item => item.trim())
77-
.filter(Boolean)
79+
const allowed =
80+
env.DOCS_CHAT_CORS_ORIGINS?.split(',')
81+
.map(item => item.trim())
82+
.filter(Boolean) || DEFAULT_CORS_ORIGINS
7883

7984
if (!origin || !allowed?.length) {
8085
return {}

0 commit comments

Comments
 (0)