fix callback URL to use configurable public base
Separate callback URL generation from LISTEN_ADDR by introducing CALLBACK_BASE_URL with a localhost default for local development. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"thuanle.me/claw-email-bridge/internal/config"
|
||||
@@ -65,7 +66,7 @@ func (d *Dispatcher) Dispatch(task *database.Task) {
|
||||
}
|
||||
|
||||
// Build callback URL.
|
||||
callbackURL := fmt.Sprintf("http://%s/callback", d.cfg.ListenAddr)
|
||||
callbackURL := buildCallbackURL(d.cfg.CallbackBaseURL)
|
||||
|
||||
payload := openClawRequest{
|
||||
Input: task.BodyPlain,
|
||||
@@ -129,6 +130,14 @@ func (d *Dispatcher) Dispatch(task *database.Task) {
|
||||
}
|
||||
}
|
||||
|
||||
func buildCallbackURL(base string) string {
|
||||
trimmed := strings.TrimRight(base, "/")
|
||||
if trimmed == "" {
|
||||
trimmed = "http://localhost"
|
||||
}
|
||||
return trimmed + "/callback"
|
||||
}
|
||||
|
||||
// callAPI makes a single HTTP POST to OpenClaw.
|
||||
func (d *Dispatcher) callAPI(payload openClawRequest) error {
|
||||
body, err := json.Marshal(payload)
|
||||
|
||||
Reference in New Issue
Block a user