Skip to content

apps-vtex: createVtexCheckoutProxy follows VTEX redirects and targets vtexcommercestable (no option to match deco-apps' proxy) #723

Open

Description

@aline-pereira

Summary

createVtexCheckoutProxy (@decocms/apps-vtex/utils/proxy, 7.80.x) diverges from the deco-apps proxy it replaces (vtex/loaders/proxy.ts → website/handlers/proxy.ts) in two ways that break real storefront flows, and neither is configurable:

  1. Redirects are followed for every path outside /checkout*, /account* and /api/vtexid/pub/logout (redirect: isCheckoutUI || isLogout ? "manual" : "follow"). deco-apps defaults to redirect: "manual" and rewrites Location instead. VtexCheckoutProxyConfig exposes no redirect option.
  2. API paths go to {account}.vtexcommercestable.{domain} (apiOrigin default) while deco-apps sends every proxied path (/api/*, /_v/*, /no-cache/*, /assets/*, /XMLData/*…) to the store's publicUrl.

Impact (measured on a VTEX store, Fresh prod × TanStack)

vtexcommercestable answers IO routes and unknown paths with 302 /Admin/Site/Login.aspx; the proxy follows it and serves the admin login page as 200 text/html, together with VTEX's vtex_session/vtex_segment/connect.sid cookies:

path Fresh (publicUrl, manual) factory
/_v/holidays 200 JSON (read by checkout6-custom.js) 200 HTML login page
/_v/public/assets/… 400 200 HTML
/no-cache/<unknown> 404 200 HTML
/assets/vtex/<unknown> 400 200 HTML
/no-cache/user/logout 302 → VTEX 200 HTML (followed twice)

Following also turns any VTEX redirect back to the storefront host (e.g. /api/vtexid/pub/authentication/redirect?returnUrl=https://<store>/…, the telesales admin login) into a subrequest to the worker's own hostname, which Cloudflare refuses (404 / 1042).

Proposal

  • Add redirect?: "manual" | "follow" to VtexCheckoutProxyConfig, defaulting to "manual" as deco-apps does (Location rewritten from the upstream origin to the storefront origin).
  • Allow routing all paths to checkoutOrigin (or default apiOrigin to it when a publicUrl-style host is given), matching deco-apps.
  • Optionally, scope every Set-Cookie to the storefront host as deco-apps' proxySetCookie does (the factory only replaces an existing Domain, so host-only VTEX cookies such as VtexWorkspace stay host-only).

Site-level workaround in deco-sites/oficina-tanstack: src/sdk/vtex/store-proxy.ts (QA-148 / QA-153).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions