fix(vtex/proxy): manual redirect for share + vtexid auth endpoints#55
Open
JonasJesus42 wants to merge 1 commit into
Open
fix(vtex/proxy): manual redirect for share + vtexid auth endpoints#55JonasJesus42 wants to merge 1 commit into
JonasJesus42 wants to merge 1 commit into
Conversation
The VTEX cart-share endpoint (/api/io/_v/share/<id>) responds 302 with
a Set-Cookie restoring the orderForm, then redirects to
/checkout?step=payment. The default redirect:"follow" in
createVtexCheckoutProxy lets the fetch consume the 302 internally, so
the intermediate Set-Cookie is dropped and the browser lands on an
empty checkout. Same pattern affects the vtexid auth-redirect endpoints
(/api/vtexid/pub/authentication/{redirect,finish}, /api/vtexid/oauth/redirect),
which carry post-login cookies and a Location that often points back to
the worker host — fetch follows it, Cloudflare sees a same-host subrequest
loop and returns 404.
Switch redirect mode to "manual" for these paths so the 302 + Set-Cookie
flow through to the browser, which then follows the Location with the
cookie applied. Existing Set-Cookie domain rewriting and Location
rewriting (lines 390/404) already handle the response correctly.
Repro: with the A/B worker active on a VTEX store, opening a cart-share
URL like /api/io/_v/share/<id>?step=payment opened /checkout with no
orderForm. Reproduced on bagaggio; framework fix unblocks every store
using createVtexCheckoutProxy without per-site worker-entry workarounds.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The VTEX cart-share endpoint (
/api/io/_v/share/<id>) responds 302 with aSet-Cookierestoring the orderForm, then redirects to/checkout?step=payment. The defaultredirect:"follow"increateVtexCheckoutProxylets the fetch consume the 302 internally, so the intermediate Set-Cookie is dropped and the browser lands on an empty checkout.The vtexid auth-redirect endpoints (
/api/vtexid/pub/authentication/{redirect,finish},/api/vtexid/oauth/redirect) hit the same trap: they carry post-login cookies and a Location that often points back to the worker host — fetch follows it, Cloudflare sees a same-host subrequest loop and returns 404.Switch
redirectto"manual"for these paths so the 302 + Set-Cookie flow through to the browser, which then follows the Location with the cookie applied. Existing Set-Cookie domain rewriting and Location rewriting in the proxy already handle the response correctly.Repro
With the A/B worker active on a VTEX store, opening a cart-share URL like
/api/io/_v/share/<id>?step=paymentopens/checkoutwith no orderForm. Reproduced on bagaggio; the production site is currently shipping a per-site worker-entry workaround (proxyManualRedirect). This framework fix unblocks every store usingcreateVtexCheckoutProxy.Test plan
step=paymentwith the shared cart appliedmanual)🤖 Generated with Claude Code
Summary by cubic
Switches
createVtexCheckoutProxyto use manual redirects for VTEX cart-share and vtexid auth endpoints so 302 responses with Set-Cookie reach the browser. Fixes empty checkout after share links and prevents 404 loops after login./api/io/_v/share/<id>) now restores the orderForm and lands on/checkout?step=payment./api/vtexid/pub/authentication/{redirect,finish},/api/vtexid/oauth/redirect) now keep post-login cookies and avoid same-host redirect loops.Written for commit 1e64377. Summary will update on new commits. Review in cubic