Просмотр исходного кода

core: allow CORS requests from *.opencode.ai subdomains

Dax Raad 1 месяц назад
Родитель
Сommit
7d2d87fa2c
1 измененных файлов с 16 добавлено и 1 удалено
  1. 16 1
      packages/opencode/src/server/server.ts

+ 16 - 1
packages/opencode/src/server/server.ts

@@ -104,7 +104,22 @@ export namespace Server {
           timer.stop()
           timer.stop()
         }
         }
       })
       })
-      .use(cors())
+      .use(
+        cors({
+          origin(input) {
+            if (!input) return
+
+            if (input.startsWith("http://localhost:")) return input
+            if (input.startsWith("http://127.0.0.1:")) return input
+
+            // *.opencode.ai (https only, adjust if needed)
+            if (/^https:\/\/([a-z0-9-]+\.)*opencode\.ai$/.test(input)) {
+              return input
+            }
+            return
+          },
+        }),
+      )
       .get(
       .get(
         "/global/health",
         "/global/health",
         describeRoute({
         describeRoute({