feat(wake): use checkoutUrl as GraphQL storefront endpoint - #1653
Conversation
Point the Storefront GraphQL client to ${checkoutUrl}/graphql instead of
the hardcoded https://storefront-api.fbits.net/graphql.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Tagging OptionsShould a new tag be published when this PR is merged?
|
📝 WalkthroughWalkthroughThe Wake storefront GraphQL endpoint now resolves ChangesWake GraphQL endpoint
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Address cubic review: use new URL("/graphql", ...) to avoid a
double-slash when checkoutUrl has a trailing slash, and fall back to
https://${account}.checkout.fbits.store when checkoutUrl is empty,
matching the checkoutApi client.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="wake/mod.ts">
<violation number="1" location="wake/mod.ts:114">
P2: The new fallback doesn't handle the empty-string case it's meant to cover. `checkoutUrl ?? ...` only guards null/undefined, but checkoutUrl is a required string and the realistic misconfig is an empty string, which flows into `new URL("/graphql", "")` and throws an uncaught TypeError during app init (both here and in createGraphqlClient's own `new URL(endpoint)`), breaking the storefront instead of degrading to the fallback. Use a truthiness check (e.g. `checkoutUrl.trim() || ...`) if the intent is to fall back when checkoutUrl is unset/empty.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| endpoint: "https://storefront-api.fbits.net/graphql", | ||
| endpoint: new URL( | ||
| "/graphql", | ||
| checkoutUrl ?? `https://${account}.checkout.fbits.store`, |
There was a problem hiding this comment.
P2: The new fallback doesn't handle the empty-string case it's meant to cover. checkoutUrl ?? ... only guards null/undefined, but checkoutUrl is a required string and the realistic misconfig is an empty string, which flows into new URL("/graphql", "") and throws an uncaught TypeError during app init (both here and in createGraphqlClient's own new URL(endpoint)), breaking the storefront instead of degrading to the fallback. Use a truthiness check (e.g. checkoutUrl.trim() || ...) if the intent is to fall back when checkoutUrl is unset/empty.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At wake/mod.ts, line 114:
<comment>The new fallback doesn't handle the empty-string case it's meant to cover. `checkoutUrl ?? ...` only guards null/undefined, but checkoutUrl is a required string and the realistic misconfig is an empty string, which flows into `new URL("/graphql", "")` and throws an uncaught TypeError during app init (both here and in createGraphqlClient's own `new URL(endpoint)`), breaking the storefront instead of degrading to the fallback. Use a truthiness check (e.g. `checkoutUrl.trim() || ...`) if the intent is to fall back when checkoutUrl is unset/empty.</comment>
<file context>
@@ -109,7 +109,11 @@ For help: https://wakecommerce.readme.io/docs/storefront-api-criacao-e-autentica
- endpoint: `${checkoutUrl}/graphql`,
+ endpoint: new URL(
+ "/graphql",
+ checkoutUrl ?? `https://${account}.checkout.fbits.store`,
+ )
+ .href,
</file context>
| checkoutUrl ?? `https://${account}.checkout.fbits.store`, | |
| checkoutUrl?.trim() || `https://${account}.checkout.fbits.store`, |
Preserve the previous default host when checkoutUrl is empty instead of pointing at the checkout store. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What
Changes the Wake Storefront GraphQL client to point at
${checkoutUrl}/graphqlinstead of the hardcodedhttps://storefront-api.fbits.net/graphql.Why
The Storefront GraphQL endpoint is now derived from the account's configured
checkoutUrl(e.g.https://checkout.erploja2.com.br), so the GraphQL API is served from the same domain as the rest of the Wake integration instead of the sharedstorefront-api.fbits.nethost.Notes
checkoutUrlis already a required app prop (wake/mod.ts), so no new configuration is needed.TCS-Access-Tokenauth header (Storefront Token) is unchanged.🤖 Generated with Claude Code
Summary by cubic
Switch the Storefront GraphQL client to
${checkoutUrl}/graphql, normalized withnew URLto prevent double slashes, and fall back tohttps://storefront-api.fbits.net/graphqlwhencheckoutUrlis empty. No config changes; theTCS-Access-Tokenheader stays the same.Written for commit 31ed376. Summary will update on new commits.
Summary by CodeRabbit