Skip to content

Routes

The storefront is a Next.js App Router app. Every URL is prefixed with the locale (/{locale}: en,de, …); nginx sends a bare / to the visitor's preferred locale. Routes are generated fromapps/theme/src/app/. Route files can't be overridden through src/custom/; their components can.

Pages

PathRendersNotes
/{locale}serverapps/theme/src/app/[locale]/(home)/page.tsx
/{locale}/{slug}serverapps/theme/src/app/[locale]/[slug]/page.tsx
/{locale}/accountclientapps/theme/src/app/[locale]/account/page.tsx
/{locale}/account/downloadsclientapps/theme/src/app/[locale]/account/downloads/page.tsx
/{locale}/account/invoicesclientapps/theme/src/app/[locale]/account/invoices/page.tsx
/{locale}/account/ordersclientapps/theme/src/app/[locale]/account/orders/page.tsx
/{locale}/account/privacyserverapps/theme/src/app/[locale]/account/privacy/page.tsx
/{locale}/account/product-alertsserverapps/theme/src/app/[locale]/account/product-alerts/page.tsx
/{locale}/account/returnsclientapps/theme/src/app/[locale]/account/returns/page.tsx
/{locale}/account/reviewsclientapps/theme/src/app/[locale]/account/reviews/page.tsx
/{locale}/account/rewardsserverapps/theme/src/app/[locale]/account/rewards/page.tsx
/{locale}/account/shipmentsclientapps/theme/src/app/[locale]/account/shipments/page.tsx
/{locale}/account/subscriptionsserverapps/theme/src/app/[locale]/account/subscriptions/page.tsx
/{locale}/account/supportclientapps/theme/src/app/[locale]/account/support/page.tsx
/{locale}/account/wishlistserverapps/theme/src/app/[locale]/account/wishlist/page.tsx
/{locale}/auth/social/completeclient

Landing page after the social-login bridge has set the magenx_ct cookie. Finishes the client side of sign-in (auth flag + guest-cart merge) and sends the customer to their account.

apps/theme/src/app/[locale]/auth/social/complete/page.tsx
/{locale}/auth/social/errorclient

Shown when the social-login bridge could not complete (misconfiguration, unverified identity, or a failed token exchange). Deliberately generic — it never leaks which step failed to the user.

apps/theme/src/app/[locale]/auth/social/error/page.tsx
/{locale}/best-sellersserverapps/theme/src/app/[locale]/best-sellers/page.tsx
/{locale}/blogserverapps/theme/src/app/[locale]/blog/page.tsx
/{locale}/blog/{slug}serverapps/theme/src/app/[locale]/blog/[slug]/page.tsx
/{locale}/blog/tag/{key}serverapps/theme/src/app/[locale]/blog/tag/[key]/page.tsx
/{locale}/brandsserverapps/theme/src/app/[locale]/brands/page.tsx
/{locale}/cartclientapps/theme/src/app/[locale]/cart/page.tsx
/{locale}/cart/recoverclient

Abandoned-cart recovery landing page.

The reminder email (Magenx_AbandonedCheckout) links here with a SIGNED, EXPIRING token as ?t=… — never the cart id itself. /api/cart/recover verifies it server-side and returns the masked id, so the credential never appears in a URL, a browser history entry or an access log, and a forwarded link stops working once the token expires.

Reminders for a signed-in customer's cart carry no token at all (Magento does not mint a guest mask for them): those links just land here and pass through to /cart, where customerCart resolves the cart from the session.

Restoring REPLACES whichever cart this browser is holding, so when there is already something in it the shopper is asked first. Silently swapping would throw away a cart they built after the email went out — and on a shared device, hand them someone else's.

apps/theme/src/app/[locale]/cart/recover/page.tsx
/{locale}/category/{...slug}serverapps/theme/src/app/[locale]/category/[...slug]/page.tsx
/{locale}/checkoutclientapps/theme/src/app/[locale]/checkout/page.tsx
/{locale}/confirm-emailserverapps/theme/src/app/[locale]/confirm-email/page.tsx
/{locale}/contactserverapps/theme/src/app/[locale]/contact/page.tsx
/{locale}/cookiesserverapps/theme/src/app/[locale]/cookies/page.tsx
/{locale}/dealsserverapps/theme/src/app/[locale]/deals/page.tsx
/{locale}/guest/orderclientapps/theme/src/app/[locale]/guest/order/page.tsx
/{locale}/order/mollie-returnclient

Mollie hosted-payment return handler.

Checkout places the order with mollie_return_url pointing here and sends the shopper to Mollie's hosted page. Mollie sends them back with payment_token and an encrypted order_id hash appended to the URL.

Flow:

  1. Take the payment token checkout stored (falling back to the URL's).
  2. mollieProcessTransaction syncs the payment status into Magento.
  3. redirect_to_success_page → clear the cart, forward to /order/success.
  4. awaiting_confirmation → the payment is not final yet (e.g. the shopper pressed back on the payment page); poll the order status for a few seconds, since the webhook may still confirm it.
  5. redirect_to_cart → Mollie has reactivated the cart; show canceled / failed with a way back to checkout.

Routing uses the booleans, never paymentStatus: OPEN is a success on bank transfer and a walk-away everywhere else, and only the booleans know that.

apps/theme/src/app/[locale]/order/mollie-return/page.tsx
/{locale}/order/paypal-returnclient

PayPal Express Checkout return handler.

PayPal redirects shoppers back here after they approve (or cancel) payment. The URL contains token and PayerID as query params on approval, or just token when the shopper cancels.

Flow (approval):

  1. Read token and PayerID from the URL plus cartId from localStorage.
  2. Call setPaymentMethodOnCart with paypal_express + payer_id + token.
  3. Call placeOrder.
  4. Clear local cart state, navigate to /order/success.

Flow (cancel / missing PayerID): Show a canceled message with a link back to /checkout so the shopper can try a different payment method.

apps/theme/src/app/[locale]/order/paypal-return/page.tsx
/{locale}/order/stripe-returnclient

Stripe payment return handler.

For redirect-based payment methods (iDEAL, EPS, Bancontact, Giropay, SOFORT, Przelewy24, …) Stripe redirects the shopper back to this page after the bank authentication step. The URL contains payment_intent, payment_intent_client_secret and redirect_status query params.

Flow:

  1. Load Stripe.js with the publishable key from Magento.
  2. Call stripe.retrievePaymentIntent(clientSecret) to fetch authoritative status.
  3. On succeeded / processing (iDEAL/EPS confirm asynchronously) → clear the cart and forward to /order/success with the pending order number.
  4. On requires_payment_method (authentication failed/canceled) → leave the cart intact, send the shopper back to /cart with a helpful message.

IMPORTANT: configure the return URL in the Magento Stripe module admin to point to this page, e.g. https://<storefront>/order/stripe-return

apps/theme/src/app/[locale]/order/stripe-return/page.tsx
/{locale}/order/successclientapps/theme/src/app/[locale]/order/success/page.tsx
/{locale}/product/{slug}serverapps/theme/src/app/[locale]/product/[slug]/page.tsx
/{locale}/reset-passwordclientapps/theme/src/app/[locale]/reset-password/page.tsx
/{locale}/searchserverapps/theme/src/app/[locale]/search/page.tsx
/{locale}/withdrawalserverapps/theme/src/app/[locale]/withdrawal/page.tsx

API routes

Server-only route handlers. Most are thin: the agentic-commerce routes (/api/ucp/**, /api/acp/**) re-export handlers from @magenxcommerce/engine/agentic.

PathMethodsNotes
/{locale}/auth/sessionPOST, DELETEapps/theme/src/app/[locale]/auth/session/route.ts
/api/acp/checkout_sessionsPOST

POST /api/acp/checkout_sessions — ACP "Create Checkout Session".

The handler lives in the engine (@magenxcommerce/engine/agentic/acp/checkout_sessions/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/acp/checkout_sessions/route.ts
/api/acp/checkout_sessions/{id}GET, POST

GET /api/acp/checkout_sessions/{id} — ACP "Get Checkout Session".

The handler lives in the engine (@magenxcommerce/engine/agentic/acp/checkout_sessions/[id]/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/acp/checkout_sessions/[id]/route.ts
/api/acp/checkout_sessions/{id}/cancelPOST

POST /api/acp/checkout_sessions/{id}/cancel — ACP "Cancel Checkout Session".

The handler lives in the engine (@magenxcommerce/engine/agentic/acp/checkout_sessions/[id]/cancel/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/acp/checkout_sessions/[id]/cancel/route.ts
/api/acp/checkout_sessions/{id}/completePOST

POST /api/acp/checkout_sessions/{id}/complete — ACP "Complete Checkout Session".

The handler lives in the engine (@magenxcommerce/engine/agentic/acp/checkout_sessions/[id]/complete/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/acp/checkout_sessions/[id]/complete/route.ts
/api/acp/discoveryGET

GET /.well-known/acp.json (rewritten to /api/acp/discovery) — the ACP discovery document.

The handler lives in the engine (@magenxcommerce/engine/agentic/acp/discovery/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/acp/discovery/route.ts
/api/assistantPOST

POST /api/assistant — one shopper message in, a Server-Sent Events stream out.

The harness lives in the engine (@magenxcommerce/engine/assistant/handler), reached through the @/lib/assistant shim so configuration runs first. The shop-specific pieces (cookie, Turnstile, client key) are in ./_lib/options.

apps/theme/src/app/api/assistant/route.ts
/api/assistant/confirmPOST

POST /api/assistant/confirm — the shopper confirms or declines an action the assistant proposed. The only route that changes anything in Magento; see @magenxcommerce/engine/assistant/confirm for the checks it runs.

apps/theme/src/app/api/assistant/confirm/route.ts
/api/auth/{...nextauth}—apps/theme/src/app/api/auth/[...nextauth]/route.ts
/api/auth/magento-sessionGETapps/theme/src/app/api/auth/magento-session/route.ts
/api/best-sellersGET

Best-seller rankings for the browser: the store-wide list (no category) for the drawers and the 404 / empty-cart rows, or one /best-sellers category tab.

── Why a route handler and not the GraphQL proxy ──

These used to run GetBestSellers through /api/graphql, which answers Cache-Control: no-store — so every drawer open, every 404, every tab click, by every visitor, was a live Magento ranking query plus a product load. getBestSellers already keeps a 'use cache' entry per (store, category) with cat_p_<id> tags for the server-rendered /best-sellers page; routing the browser through it means Magento ranks each list at most once per TTL for the whole store, the same trade /api/product-links makes for PDP rails. GetBestSellers is server-only as a result.

Only the page's own tab ids are served: category reaches a 'use cache' key, so accepting any integer would let a scanner mint one entry per id. limit merely slices the shared entry.

apps/theme/src/app/api/best-sellers/route.ts
/api/brand-productsGETapps/theme/src/app/api/brand-products/route.ts
/api/cart/recoverPOST

POST /api/cart/recover — redeem an abandoned-cart reminder token.

The reminder email (Magenx_AbandonedCheckout) links to /[locale]/cart/recover with a signed token, NOT with the cart id. A masked cart id is a bearer credential — see the warning on adoptCart in the engine's cart-context — so putting one in an email link would spread it through browser history, access logs and any analytics that records location.href, and it would never expire, because rotating it would break the shopper's live session.

This route is the only place the two are joined: it verifies the HMAC and the expiry with a secret shared with Magento, and hands the browser the masked id only then. The secret must never reach the client bundle, which is why this is a route handler and not a client-side check.

apps/theme/src/app/api/cart/recover/route.ts
/api/dealsGET

Deals for the browser: the store-wide list (no type) for the wishlist drawer and the 404 / empty-cart rows, or one /deals type tab. Same reasoning as /api/best-sellers: through the no-store GraphQL proxy, each of those was a live Magento query per visitor; here they share getDeals' 'use cache' entries (the store-wide one is what the /deals page's "All" grid renders from). GetDeals is server-only as a result. limit only slices.

apps/theme/src/app/api/deals/route.ts
/api/download/{id}GET

GET /api/download/[id] — Magenx_ProductAttachments file/link download.

The PDP never learns a real file path or external URL — it only carries an opaque attachment id (see ProductAttachmentChips / fragments.ts). This route resolves that id server-to-server via the productAttachmentDownload query (deliberately kept off the /api/graphql persisted-query allowlist — see SERVER_ONLY_OPERATIONS — so only this server-side call can reach it, never a browser), then fetches and streams the bytes itself, so the browser's network tab shows only this URL, never a pub/media path or an external host.

apps/theme/src/app/api/download/[id]/route.ts
/api/downloads/{hash}GET

GET /api/downloads/[hash] — a purchased downloadable product's file.

Magento's own download route, downloadable/download/link/id/<link_hash>/, is a Luma controller: for a non-shareable link it wants a Magento frontend session (cookie), which a headless storefront never has, and it ignores the customer token. For a link marked "Shareable" it skips that session check and authorizes on the hash alone, still enforcing the link's status and its remaining-downloads count. This route relies on that:

  1. The customer token (httpOnly magenx_ct cookie) must be present.
  2. customerDownloadableProducts, run with that token, returns only the customer's own links. The hash must be one of them — this is the ownership check Magento skips for shareable links.
  3. Magento's download route is then fetched server-to-server on the internal nginx listener (the origin of MAGENTO_GRAPHQL_ENDPOINT) and the file is streamed back. Magento counts the download, expires the link at its limit, and serves both uploaded files and external-URL links.

The public vhost never routes downloadable/... to Magento (it 307s locale-less paths to the storefront), so the shareable hash cannot be used to bypass this route from outside. Links must be set to Shareable in Magento (Stores → Configuration → Catalog → Downloadable Product Options → Shareable = Yes, or per link); otherwise Magento answers with its login redirect and the shopper gets the "unavailable" message.

apps/theme/src/app/api/downloads/[hash]/route.ts
/api/graphqlGET, POST

/api/graphql — the storefront's GraphQL proxy to Magento and its security chokepoint. The policy lives in the _lib modules; this file is only the POST pipeline that composes them, in order:

  1. body size cap (_lib/constants — 413 before anything reads or parses it)
  2. parse ONCE (_lib/request — JSON + every query AST, shared by every step below)
  3. persisted-query allowlist (_lib/allowlist — 403 unknown query shapes)
  4. AST operation names (_lib/operation-names — the ONLY safe input for name-based decisions; never the client-supplied operationName)
  5. Turnstile verification (_lib/turnstile — 403 protected ops without a token verified against Cloudflare for success + action + hostname; fails closed)
  6. auth header construction (cookie → Authorization: Bearer, except for guest-only requests — _lib/guest-ops)
  7. sender rewrite (_lib/sender-rewrite — SendEmailToFriend sender comes from the session, not the browser)
  8. upstream fetch (_lib/profiling — OTel span + Server-Timing)

GET is a separate, much narrower path (see GET below and _lib/persisted-get): guest-cacheable reads named by hash only, forwarded with no customer token, with a Cache-Control that nginx's graphql_get zone honours.

Adding a client-run operation? Add it to _lib/allowed-operations.ts. Adding an abuse-prone public mutation? Also add it to TURNSTILE_PROTECTED_OPERATIONS in _lib/turnstile.ts, mapped to its form's widget action. See CLAUDE.md for the history and gotchas.

apps/theme/src/app/api/graphql/route.ts
/api/product-blog-postsGETapps/theme/src/app/api/product-blog-posts/route.ts
/api/product-linksGETapps/theme/src/app/api/product-links/route.ts
/api/revalidatePOSTapps/theme/src/app/api/revalidate/route.ts
/api/ucp/cartsPOST

POST /api/ucp/carts — UCP "Create Cart" (dev.ucp.shopping.cart).

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/carts/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/carts/route.ts
/api/ucp/carts/{id}GET, PUT

GET /api/ucp/carts/{id} — UCP "Get Cart"

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/carts/[id]/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/carts/[id]/route.ts
/api/ucp/carts/{id}/cancelPOST

POST /api/ucp/carts/{id}/cancel — UCP "Cancel Cart".

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/carts/[id]/cancel/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/carts/[id]/cancel/route.ts
/api/ucp/catalog/lookupPOST

POST /api/ucp/catalog/lookup — UCP "Lookup Catalog (batch)" (dev.ucp.shopping.catalog.lookup).

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/catalog/lookup/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/catalog/lookup/route.ts
/api/ucp/catalog/productPOST

POST /api/ucp/catalog/product — UCP "Get Product" (dev.ucp.shopping.catalog.lookup).

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/catalog/product/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/catalog/product/route.ts
/api/ucp/catalog/searchPOST

POST /api/ucp/catalog/search — UCP "Search Catalog" (dev.ucp.shopping.catalog.search).

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/catalog/search/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/catalog/search/route.ts
/api/ucp/checkout-sessionsPOST

POST /api/ucp/checkout-sessions — UCP "Create Checkout".

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/checkout-sessions/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/checkout-sessions/route.ts
/api/ucp/checkout-sessions/{id}GET, PUT

GET /api/ucp/checkout-sessions/{id} — UCP "Get Checkout"

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/checkout-sessions/[id]/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/checkout-sessions/[id]/route.ts
/api/ucp/checkout-sessions/{id}/cancelPOST

POST /api/ucp/checkout-sessions/{id}/cancel — UCP "Cancel Checkout".

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/checkout-sessions/[id]/cancel/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/checkout-sessions/[id]/cancel/route.ts
/api/ucp/checkout-sessions/{id}/completePOST

POST /api/ucp/checkout-sessions/{id}/complete — UCP "Complete Checkout".

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/checkout-sessions/[id]/complete/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/checkout-sessions/[id]/complete/route.ts
/api/ucp/mcpPOST

POST /api/ucp/mcp — the UCP capabilities (checkout, catalog, cart, order)

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/mcp/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/mcp/route.ts
/api/ucp/orders/{id}GET

GET /api/ucp/orders/{id} — UCP "Get Order" (dev.ucp.shopping.order).

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/orders/[id]/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/orders/[id]/route.ts
/api/ucp/profileGET

GET /.well-known/ucp (rewritten to /api/ucp/profile) — the UCP business profile.

The handler lives in the engine (@magenxcommerce/engine/agentic/ucp/profile/route.ts); this file only routes the URL to it. See src/lib/agentic.ts.

apps/theme/src/app/api/ucp/profile/route.ts
/llms.txtGET

Dynamic llms.txt generator (https://llmstxt.org).

Mirrors the robots.ts / manifest.ts metadata-route pattern: the file is generated at request time from magenx.config.ts (brand, navigation, locales) rather than hand-maintained as a static public/llms.txt, so it tracks NEXT_PUBLIC_SITE_URL and any nav-link changes automatically.

Served at /llms.txt.

NB: no export const dynamic/runtime segment config — cacheComponents is enabled (next.config.ts) and rejects route-segment config at build time. CDN caching is handled by the Cache-Control header below instead.

apps/theme/src/app/llms.txt/route.ts