Skip to content

Keep the storefront exit page working in the theme dev server - #9012

Open
jplhomer wants to merge 2 commits into
mainfrom
jplhomer/theme-dev-server-url-navigate
Open

jplhomer wants to merge 2 commits into
mainfrom
jplhomer/theme-dev-server-url-navigate

Conversation

@jplhomer

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

In shopify theme dev and theme app extension previews in shopify app dev, clicking a link to another site always showed the storefront's "leaving this store" confirmation page. That happened even when the live store or the admin theme preview sends the shopper straight there.

The dev server's proxy caused it in two ways:

  1. The storefront's exit page (/url) only continues to another site when the request is a real navigation (Sec-Fetch-Mode: navigate). The browser sends that header to the local server. The CLI then re-sends the request with Node's global fetch, which always replaces Sec-Fetch-Mode with its own request mode (cors). So the storefront showed the confirmation page every time.
  2. Even when the storefront did redirect, the proxy stripped the origin from every Location header. https://example.com/ became /, and the shopper landed back on the local server.

WHAT is this pull request doing?

  • storefront-renderer.ts: a GET to the exit page (/url or /:locale/url) is sent with cli-kit's fetch (node-fetch), which forwards the browser's Sec-Fetch-* headers unchanged.
    • It sends the same headers and cookies as other render requests and keeps redirect: 'manual' and the same error handling.
    • It uses slow-request mode, so there are no retries and no timeout, the same as the global fetch.
    • The response is converted to a web Response, and every Set-Cookie is kept.
    • The exit page doesn't render theme templates, so this request is always a GET, even when there are unsynced local templates.
    • Every other page still renders the same way as before.
  • proxy.ts: a Location header is only turned into a local path when it points to the store (a relative path or the store's domain). Redirects to other hosts stay absolute. For store redirects, the existing _fd/pb cleanup and the checkout exception are unchanged.

How to manually test your changes?

  1. Use a store whose storefront shows a confirmation page before shoppers leave for another site. Run shopify theme dev, or shopify app dev with a theme app extension, using this branch.
  2. In the local preview, click a link to another site (e.g. https://example.com/).
    • Before: the confirmation page shows for every external link. If the storefront does redirect, you end up back on the local server.
    • After: the preview behaves like the admin theme preview. Links the storefront allows go straight to the other site, and the confirmation page only shows when it would show there too.
  3. Links within the store, the store's own redirects (for example /cart or localization redirects) and checkout should work as before.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 26, 2026
@jplhomer
jplhomer marked this pull request as ready for review October 26, 2026 15:29
@jplhomer
jplhomer requested a review from a team as a code owner October 26, 2026 15:30
Copilot AI balanced review requested due to automatic review settings October 26, 2026 15:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

This branch has not been deployed

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

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants