diff --git a/kbdb/src/index.ts b/kbdb/src/index.ts index f2095ed..7e48bbf 100644 --- a/kbdb/src/index.ts +++ b/kbdb/src/index.ts @@ -4,6 +4,7 @@ // Base = D1 only (free, no credit card): entries / templates / records + LIKE search + recipe-stats. // Optional modules (NOT in this base): embed (Vectorize+AI binding, semantic search), triplet (separate repo). import { Hono } from 'hono'; +import { cors } from 'hono/cors'; import type { Bindings } from './types'; import { entryRoutes } from './routes/entries'; import { templateRoutes } from './routes/templates'; @@ -13,6 +14,13 @@ import { embedRoutes } from './routes/embed'; const app = new Hono<{ Bindings: Bindings }>(); +// CORS(leo 2026-07-05 明示同意;arcrun mindset §6「暴露資料要人類明示同意」): +// 讓瀏覽器(mira 前台 mira.uncle6.me 等)能「讀」KBDB 做大眾化語義搜尋。 +// 只放行 GET 跨源讀取(+ OPTIONS preflight);不開 POST/寫入跨源——寫入本就裸開, +// 但不讓任意瀏覽器 origin 直接寫進 KBDB。origin:'*' 涵蓋 leo 之後 DNS 指向的任何網域。 +// 正路是走 cypher-proxy(有 auth,mira §1.7);此為過渡(worker 現本就裸開無 auth)。 +app.use('*', cors({ origin: '*', allowMethods: ['GET', 'OPTIONS'], allowHeaders: ['Content-Type'] })); + app.get('/', (c) => c.json({ service: 'arcrun-kbdb', tier: 'base', status: 'ok' })); app.get('/health', (c) => c.json({ ok: true }));