File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { stop, bindAbort } from "./process.js"
55export type ServerOptions = {
66 hostname ?: string
77 port ?: number
8+ cors ?: string | string [ ]
89 signal ?: AbortSignal
910 timeout ?: number
1011 config ?: Config
@@ -31,6 +32,10 @@ export async function createOpencodeServer(options?: ServerOptions) {
3132
3233 const args = [ `serve` , `--hostname=${ options . hostname } ` , `--port=${ options . port } ` ]
3334 if ( options . config ?. logLevel ) args . push ( `--log-level=${ options . config . logLevel } ` )
35+ if ( options . cors ) {
36+ const origins = Array . isArray ( options . cors ) ? options . cors : [ options . cors ]
37+ for ( const origin of origins ) args . push ( `--cors=${ origin } ` )
38+ }
3439
3540 const proc = launch ( `opencode` , args , {
3641 env : {
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { stop, bindAbort } from "../process.js"
55export type ServerOptions = {
66 hostname ?: string
77 port ?: number
8+ cors ?: string | string [ ]
89 signal ?: AbortSignal
910 timeout ?: number
1011 config ?: Config
@@ -31,6 +32,10 @@ export async function createOpencodeServer(options?: ServerOptions) {
3132
3233 const args = [ `serve` , `--hostname=${ options . hostname } ` , `--port=${ options . port } ` ]
3334 if ( options . config ?. logLevel ) args . push ( `--log-level=${ options . config . logLevel } ` )
35+ if ( options . cors ) {
36+ const origins = Array . isArray ( options . cors ) ? options . cors : [ options . cors ]
37+ for ( const origin of origins ) args . push ( `--cors=${ origin } ` )
38+ }
3439
3540 const proc = launch ( `opencode` , args , {
3641 env : {
You can’t perform that action at this time.
0 commit comments