v0.9.2 web and wasm changes for deployment
This commit is contained in:
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
5
cmd/chess-client-cli/url_native.go
Normal file
5
cmd/chess-client-cli/url_native.go
Normal file
@ -0,0 +1,5 @@
|
||||
//go:build !js
|
||||
|
||||
package main
|
||||
|
||||
const defaultAPIBase = "http://localhost:8080"
|
||||
11
cmd/chess-client-cli/url_wasm.go
Normal file
11
cmd/chess-client-cli/url_wasm.go
Normal 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"
|
||||
Reference in New Issue
Block a user