Skip to content

Commit 7d2d87f

Browse files
committed
core: allow CORS requests from *.opencode.ai subdomains
1 parent 787f37b commit 7d2d87f

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎packages/opencode/src/server/server.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,22 @@ export namespace Server {
104104
timer.stop()
105105
}
106106
})
107-
.use(cors())
107+
.use(
108+
cors({
109+
origin(input) {
110+
if (!input) return
111+
112+
if (input.startsWith("http://localhost:")) return input
113+
if (input.startsWith("http://127.0.0.1:")) return input
114+
115+
// *.opencode.ai (https only, adjust if needed)
116+
if (/^https:\/\/([a-z0-9-]+\.)*opencode\.ai$/.test(input)) {
117+
return input
118+
}
119+
return
120+
},
121+
}),
122+
)
108123
.get(
109124
"/global/health",
110125
describeRoute({

0 commit comments

Comments
 (0)