Redirects
Your store's URL redirects live on the platform: the ones you make in the admin (Content, URL redirects) and the ones Cartbase writes itself when a product, collection, page or post handle is renamed, so a rename never breaks an old address.
On a hosted store you wire nothing. The proxy Cartbase injects into every deploy keeps your store's redirect table, read from the platform once a minute, and answers a moved address with a permanent redirect (308) before any page runs, the query string travelling with the visitor. A redirect you add in the admin lands within a minute.
A store hosted elsewhere does the same from its own proxy with the table
below. The per-path lookup stays for a store with no proxy at all: its
not-found handler asks about the missed path and redirects when the answer
is not null.
GET /api/store/url-redirects/table — the whole table
- Purpose: every live redirect of the store, oldest first.
- Auth: anon (
x-client-id). - Response:
{
"redirects": [{ "from_path": "/store", "to_path": "/collections/all-products" }],
"count": 1, // how many live redirects the store has
"max": 5000 // the most rows one answer holds
}- Used by: the injected proxy; a proxy of your own on another host.
GET /api/store/url-redirects?path=… — one path
- Purpose: resolve one missed pathname (e.g.
/products/old-handle) to its redirect target, if any. Exact match, index-covered on(client_id, from_path). Call it only for pages that are not found, never on a page load. - Auth: anon (
x-client-id). - Request: query
{path}— the exact pathname that 404'd (leading slash included), min length 1. - Response:
{
"path": "/products/old-handle", // echoed
"to_path": "/products/new-handle" // or null — no redirect, render the 404
}- Errors:
400 validation_failed(missing/emptypath) ·400 missing_client_id. - SDK:
redirects.lookupRedirect(client, path) - Settings: admin → Content → URL redirects; automatic rows on handle renames.
# Miss → to_path null (the everyday 404 case), echo intact.
BODY=$(curl -sf "$BASE/api/store/url-redirects?path=/doc-no-such-path-$RUN" \
-H "x-client-id: $CLIENT_ID")
echo "$BODY" | grep -q '"to_path":null'
echo "$BODY" | grep -q "doc-no-such-path-$RUN"
# Missing path param → 400.
STATUS=$(curl -s -o /dev/null -w '%{http_code}' "$BASE/api/store/url-redirects" \
-H "x-client-id: $CLIENT_ID")
test "$STATUS" = 400
# The table answers for every store, empty or not.
curl -sf "$BASE/api/store/url-redirects/table" -H "x-client-id: $CLIENT_ID" | grep -q '"max":5000'The hit case (
to_pathnon-null) requires an admin-created redirect row; it is pinned executably bytests/store/url-redirects-lookup.test.tsand the SDK contract testtests/contract/sdk-content.contract.test.ts.