feat(kbdb): CORS 放行瀏覽器 GET 讀取(leo 同意,mindset §6)——mira 大眾化語義搜尋前台可直讀 KBDB

- hono/cors: origin:'*' 只 GET+OPTIONS(讀),不開跨源寫入
- 過渡:worker 現裸開無 auth;正路走 cypher-proxy(mira §1.7)
This commit is contained in:
Claude
2026-07-05 14:26:03 +00:00
parent ed2e42e007
commit 7d5426d95a
+8
View File
@@ -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 }>();
// CORSleo 2026-07-05 明示同意;arcrun mindset §6「暴露資料要人類明示同意」):
// 讓瀏覽器(mira 前台 mira.uncle6.me 等)能「讀」KBDB 做大眾化語義搜尋。
// 只放行 GET 跨源讀取(+ OPTIONS preflight);不開 POST/寫入跨源——寫入本就裸開,
// 但不讓任意瀏覽器 origin 直接寫進 KBDB。origin:'*' 涵蓋 leo 之後 DNS 指向的任何網域。
// 正路是走 cypher-proxy(有 authmira §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 }));