v0.9.2 web and wasm changes for deployment

This commit is contained in:
2026-02-27 18:35:49 -05:00
parent fc8a6ba6a6
commit 16fc069a8f
4 changed files with 54 additions and 27 deletions

View File

@ -30,8 +30,8 @@ func runClient() (restart bool) {
}()
s := &session.Session{
APIBaseURL: "http://localhost:8080",
Client: api.New("http://localhost:8080"),
APIBaseURL: defaultAPIBase,
Client: api.New(defaultAPIBase),
Verbose: false,
}
@ -132,4 +132,5 @@ func buildPrompt(s *session.Session) string {
}
return display.Prompt(b.String())
}
}

View File

@ -0,0 +1,5 @@
//go:build !js
package main
const defaultAPIBase = "http://localhost:8080"

View File

@ -0,0 +1,11 @@
//go:build js && wasm
package main
import "syscall/js"
// Derive base URL from the page's own origin at runtime
// When served via nginx at domain.com, origin = "https://domain.com"
// and the chess API proxy lives at /chess — so BaseURL = "https://comain.com/chess".
// Works correctly for any deployment domain without rebuilding
var defaultAPIBase = js.Global().Get("location").Get("origin").String() + "/chess"