fix
This commit is contained in:
parent
c08b7c1f63
commit
a1942c0054
2 changed files with 8 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
|
@ -56,10 +57,15 @@ func (a *App) ensureCaddyRoute(ctx context.Context, p Project) error {
|
|||
if !a.cfg.CaddyRouteEnabled {
|
||||
return nil
|
||||
}
|
||||
projectDir, err := a.projectDirFor(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
socketPath := filepath.Join(projectDir, "app.sock")
|
||||
route := map[string]any{
|
||||
"@id": "project-route-" + p.UserID + "-" + p.Slug,
|
||||
"match": []any{map[string]any{"host": []string{p.RouteHost}}},
|
||||
"handle": []any{map[string]any{"handler": "reverse_proxy", "upstreams": []any{map[string]any{"dial": fmt.Sprintf("127.0.0.1:%d", p.TargetPort)}}}},
|
||||
"handle": []any{map[string]any{"handler": "reverse_proxy", "upstreams": []any{map[string]any{"dial": "unix/" + socketPath}}}},
|
||||
}
|
||||
body, _ := json.Marshal(route)
|
||||
url := fmt.Sprintf("%s/config/apps/http/servers/%s/routes", a.cfg.CaddyAdminURL, a.cfg.CaddyServerID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue