Skip to content

Remove Agent-specific proxy routes - #3946

Open
FCalabria wants to merge 1 commit into
Shopify:previewfrom
FCalabria:remove-agent-specific-proxy
Open

Remove Agent-specific proxy routes#3946
FCalabria wants to merge 1 commit into
Shopify:previewfrom
FCalabria:remove-agent-specific-proxy

Conversation

@FCalabria

@FCalabria FCalabria commented Aug 13, 2026

Copy link
Copy Markdown

Depends on Storefront Components #1656.

Why are these changes introduced?

Hydrogen preview added a dedicated proxy for direct Storefront Agent routes before Storefront Agent could use the generic Shopify API proxy. Storefront Components now builds buyer-claims requests with apiProxyPrefix, so keeping both paths would duplicate routing and header behavior.

What approach did you take?

Use the generic /__shopify/* proxy as the only Storefront Agent proxy on Hydrogen preview. The browser-facing proxy also removes infrastructure control headers before forwarding requests to Shopify.

Decision logs

Why is removal safe now? Storefront Components #1656 is in production. The served Agent bundle constructs the buyer-claims URL from apiProxyPrefix, and its ten-minute CDN cache window has elapsed. Stable Hydrogen releases never proxied these direct Agent paths because this work targets preview.

What happens to older Agent bundles? Unprefixed /agent/buyer-claims and /agent/handoff requests fall through to app routing, which may return a 404 or catch-all HTML response. Already-running tabs can retain an older bundle until reload, so this PR remains gated on the Phase 3 bake.

How is this reversed? There is no runtime flag. Reversal requires restoring the previous Hydrogen package behavior, publishing it, and merchants upgrading and redeploying. The preview-only release limits exposure but does not provide an instant rollback.

Why remove infrastructure control headers? The generic proxy accepts browser requests. It must not forward browser-supplied values that Shopify infrastructure uses for staff-only or staging behavior.

Testing steps/scenarios

  • 40 request-routing tests
  • Hydrogen package typecheck
  • Repository lint and formatting hooks
  • Production Agent bundle constructs buyer claims through apiProxyPrefix

@fredericoo
fredericoo marked this pull request as ready for review August 13, 2026 18:32
@fredericoo
fredericoo requested a review from a team as a code owner August 13, 2026 18:32
@fredericoo
fredericoo marked this pull request as draft August 13, 2026 18:33
@frandiox frandiox self-assigned this Aug 14, 2026

@frandiox frandiox 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.

The pending PRs are already merged. I think we are missing a release in Storefront Components.

Comment on lines +95 to +107
it.each(["handoff", "buyer-claims"])(
"proxies agent %s through the Shopify API proxy",
async (route) => {
const result = await handleShopifyRoutes({
request: new Request(`https://my-app.com/__shopify/agent/${route}`),
});

expect(result).toBeInstanceOf(Response);
const call = mockFetch.mock.calls[0];
assert(call, "expected fetch to be called");
expect(call[0].href).toBe(`https://test-store.myshopify.com/agent/${route}`);
},
);

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.

This test can be now made generic, not specific to the agent. It should just forward anything (except /cdn/). Perhaps just revert the change to the previous version?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Restored the generic Shopify API proxy test in b2f3148a. Agent routes use the same /__shopify contract as every other proxied path.

Comment on lines +332 to +342
it.each(["handoff", "buyer-claims"])(
"leaves direct agent %s routes to the app router",
(route) => {
const result = handleShopifyRoutes({
request: new Request(`https://my-app.com/agent/${route}`),
});

expect(result).toBeNull();
expect(mockFetch).not.toHaveBeenCalled();
});
expect(result).toBeNull();
expect(mockFetch).not.toHaveBeenCalled();
},
);

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.

Same with this one, it should do be reverted to "returns null synchronously for non-matching URLs" or similar.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Restored the generic synchronous non-match test in b2f3148a. Direct Agent routes now use the shared app-router contract.

@FCalabria
FCalabria force-pushed the remove-agent-specific-proxy branch from a4dd396 to 1e965e1 Compare August 19, 2026 11:44
@FCalabria
FCalabria marked this pull request as ready for review August 19, 2026 11:47
@FCalabria
FCalabria force-pushed the remove-agent-specific-proxy branch from 1e965e1 to b2f3148 Compare August 19, 2026 13:53
@FCalabria

FCalabria commented Aug 19, 2026

Copy link
Copy Markdown
Author

@frandiox yes, Storefront Components #1656 has merged but still needs a production release. I'll keep #3946 blocked until that release is live and cached direct-route bundles have expired.

danrosenthal

This comment was marked as off-topic.

@FCalabria
FCalabria force-pushed the remove-agent-specific-proxy branch from b2f3148 to a2ac80d Compare August 20, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants