feat(providers): account calls (auth/refresh/credits) egress on the local IP

Now only the generate/video submit uses proxy.url; cookie-exchange/login, token refresh, credit-balance and project/session bootstrap all go direct. Also splits adobe GenerateVideo (submit=proxy, poll/download=local). Verified live: adobe gpt 1K cookie-exchange via local IP, submit 23.244.30.102 (proxy) vs local 76.209.9.65, 2.0MB PNG. Build+vet pass.
This commit is contained in:
2026-07-09 16:36:04 +08:00
parent 6c2a942a88
commit 622bc9ba9a
7 changed files with 23 additions and 17 deletions
+3 -3
View File
@@ -139,7 +139,7 @@ func (c *Client) RefreshIfNeeded(ctx context.Context, cookie string) (string, bo
}
func (c *Client) refreshPost(ctx context.Context, refreshToken string) ([]byte, int, error) {
client, err := c.newTLSClient()
client, err := c.newDirectTLSClient()
if err != nil {
return nil, 0, err
}
@@ -307,7 +307,7 @@ func (c *Client) FetchCreditsBalance(ctx context.Context, cookie string) (map[st
defer cancel()
// NOTE: no /app here — the heavy SSR activation is done separately (on recovery
// and at generation via Activate). This probe just reads the current balance.
body, status, err := c.apiGet(probeCtx, cookie, "/api/billing-data")
body, status, err := c.apiGetP(probeCtx, cookie, "/api/billing-data", false)
if err != nil {
return unknownBalance("network: " + err.Error()), nil
}
@@ -366,7 +366,7 @@ func (c *Client) Activate(ctx context.Context, cookie string) {
}
actCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 60*time.Second)
defer cancel()
_, _, _ = c.apiGet(actCtx, cookie, "/app")
_, _, _ = c.apiGetP(actCtx, cookie, "/app", false)
c.mu.Lock()
c.actAt[key] = time.Now().Unix()
c.mu.Unlock()
+3 -2
View File
@@ -22,7 +22,7 @@ const (
// ensureProject returns a flux project id for the account: the first existing
// project, or a freshly created one. Generation requires a project.
func (c *Client) ensureProject(ctx context.Context, cookie string) (string, error) {
body, status, err := c.apiGet(ctx, cookie, "/api/flux-projects")
body, status, err := c.apiGetP(ctx, cookie, "/api/flux-projects", false)
if err != nil {
return "", fmt.Errorf("%w: list projects: %s", ErrTemporaryUpstream, err.Error())
}
@@ -309,6 +309,7 @@ func (c *Client) apiPostP(ctx context.Context, cookie, path, contentType string,
}
func (c *Client) apiPostJSON(ctx context.Context, cookie, path string, payload any) ([]byte, int, error) {
// project bootstrap runs on the local IP; only the generate submit uses the proxy.
b, _ := json.Marshal(payload)
return c.apiPost(ctx, cookie, path, "application/json", b)
return c.apiPostP(ctx, cookie, path, "application/json", b, false)
}