Repository navigation
Explain when a Commerce route answers with the app's HTML page - #1530
Open
sbolinger-godaddy wants to merge 1 commit into
Open
sbolinger-godaddy wants to merge 1 commit into
sbolinger-godaddy wants to merge 1 commit into
Conversation
When a host never mounts /api/commerce, its single-page app or SSR fallback answers with index.html and a 200, and the storefront showed a JSON parse error: Unexpected token '<', "<!doctype "... is not valid JSON. A successful text/html response is now a failure with readable text, "The store could not be reached. Please retry.", in English and French. It never shows sample products. Development builds log the route once and say where to mount the Commerce routes. The server README shows the setup for a site before its store connects, and the storefront README has a troubleshooting entry for the error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 0c7f6cc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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
A template with no connected store showed
Unexpected token '<', "<!doctype "... is not valid JSONin place of its catalog. Its server never mounted/api/commerce, so the SSR catch-all answeredGET /api/commerce/configwithindex.htmland a 200. The storefront only read the body of failed responses, so it passed the page toresponse.json().text/htmlresponse is now a failure.checkedFetchthrows anApiErrorwith the newapiUnavailabletext: "The store could not be reached. Please retry." in English and "La boutique est injoignable. Veuillez réessayer." in French. The check is incheckedFetch, so it covers everyrequest()call and the cart's add path.unbound, so a connected store with a broken deployment never shows fake products.[gd-commerce-storefront] /api/commerce/config returned an HTML page instead of JSON. Mount the commerce routes at /api/commerce on this origin, before any static file or single-page app fallback route.createCommerceCatalogRouter, an explicitreadConnectionState(), and mounting the routes before static and fallback routes.text/htmlsuccess is treated as a failure.The server example reads the connection state from an explicit setting. While fixing the template, an agent inferred
unboundfrom a missingGODADDY_STORE_ID, which both packages forbid: a connected store that lost the variable would quietly show samples.Screenshots
Before

After

Changeset
@godaddy/gd-commerce-storefrontpatch). The server package changes are docs only.Test Plan
storefront.test.tsx. Both fail without the change:request()andaddToCartturn an HTML 200 into anApiErrorwithapiUnavailabletext, and the console message appears once per route.pnpm --filter @godaddy/gd-commerce-storefront build,typecheck,lintandtestpass (184 tests), and the example app builds.html-apicheck passes 5 of 5 on this branch and fails 5 of 5 on main. It covers the catalog, sample catalog, product page, retry once routes answer, and one console message per page load after more/configrequests.