Description
Navigating to any auth page (e.g. /login.php) while running stencil start
results in a 500 error. The local server crashes with:
TypeError: Cannot read properties of undefined (reading 'token')
at internals.parseResponse (server/plugins/renderer/renderer.module.js:222:81)
Root Cause
In parseResponse, the CLI unconditionally reads settings.storefront_api.token
to fetch Page Builder regions via GraphQL:
if (pageType) {
regionResponse = await contentApiClient.getRenderedRegionsByPageType({
accessToken: response2.data.context.settings.storefront_api.token,
...
});
}
BigCommerce does not include storefront_api in the page context for auth pages
(login, create account, forgot password, etc.). This makes storefront_api
undefined, and the .token access throws.
Steps to Reproduce
- Run
stencil start against any store
- Navigate to http://localhost:3000/login.php
- Observe 500 response and the TypeError in the terminal
Expected Behaviour
Auth pages render normally. They contain no Page Builder regions requiring a
Storefront API token, so the GraphQL fetch should be skipped or handled gracefully.
Suggested Fix
Guard before the fetch:
if (pageType && response2.data.context.settings.storefront_api) {
Or use optional chaining:
accessToken: response2.data.context.settings.storefront_api?.token,
Environment
- @bigcommerce/stencil-cli: 9.0.1 (also present in 9.0.0)
- Node.js: v24.14.1
- OS: macOS
- Affected pages: /login.php and any auth page where BigCommerce omits
storefront_api from the context
Description
Navigating to any auth page (e.g.
/login.php) while runningstencil startresults in a 500 error. The local server crashes with:
Root Cause
In
parseResponse, the CLI unconditionally readssettings.storefront_api.tokento fetch Page Builder regions via GraphQL:
BigCommerce does not include
storefront_apiin the page context for auth pages(login, create account, forgot password, etc.). This makes
storefront_apiundefined, and the
.tokenaccess throws.Steps to Reproduce
stencil startagainst any storeExpected Behaviour
Auth pages render normally. They contain no Page Builder regions requiring a
Storefront API token, so the GraphQL fetch should be skipped or handled gracefully.
Suggested Fix
Guard before the fetch:
Or use optional chaining:
Environment
storefront_apifrom the context