feat(wake): use checkoutUrl as GraphQL storefront endpoint - #1653
feat(wake): use checkoutUrl as GraphQL storefront endpoint#1653guitavano wants to merge 1 commit into
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?
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Wake storefront GraphQL endpoint now uses 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.
2 issues found across 1 file
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:112">
P2: Trailing slash in `checkoutUrl` produces double-slash path `//graphql`. If `checkoutUrl` ends with `/`, interpolation yields `https://...//graphql` which some servers reject as a 404. `wake/hooks/context.ts:89` already uses the safe `new URL('/graphql', checkoutUrl)` pattern — follow that same pattern here.</violation>
<violation number="2" location="wake/mod.ts:112">
P2: The `checkoutApi` on line 117 defensively falls back to a default URL with `checkoutUrl ?? \`https://${account}.checkout.fbits.store\``, but the storefront GraphQL endpoint on the changed line uses `${checkoutUrl}/graphql` with no fallback at all. If `checkoutUrl` is somehow empty, undefined, or resolves to an empty string at runtime, the storefront client will break — its endpoint would be `/graphql` (a relative URL) instead of an absolute one.
Recommendation: apply the same fallback pattern used for `checkoutApi`, e.g., `` `\${checkoutUrl ?? `https://${account}.checkout.fbits.store`}/graphql` `` or normalize `checkoutUrl` once at the top of `App()`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| //22e714b360b7ef187fe4bdb93385dd0a85686e2a | ||
| const storefront = createGraphqlClient({ | ||
| endpoint: "https://storefront-api.fbits.net/graphql", | ||
| endpoint: `${checkoutUrl}/graphql`, |
There was a problem hiding this comment.
P2: Trailing slash in checkoutUrl produces double-slash path //graphql. If checkoutUrl ends with /, interpolation yields https://...//graphql which some servers reject as a 404. wake/hooks/context.ts:89 already uses the safe new URL('/graphql', checkoutUrl) pattern — follow that same pattern here.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At wake/mod.ts, line 112:
<comment>Trailing slash in `checkoutUrl` produces double-slash path `//graphql`. If `checkoutUrl` ends with `/`, interpolation yields `https://...//graphql` which some servers reject as a 404. `wake/hooks/context.ts:89` already uses the safe `new URL('/graphql', checkoutUrl)` pattern — follow that same pattern here.</comment>
<file context>
@@ -109,7 +109,7 @@ For help: https://wakecommerce.readme.io/docs/storefront-api-criacao-e-autentica
//22e714b360b7ef187fe4bdb93385dd0a85686e2a
const storefront = createGraphqlClient({
- endpoint: "https://storefront-api.fbits.net/graphql",
+ endpoint: `${checkoutUrl}/graphql`,
headers: new Headers({ "TCS-Access-Token": `${stringStorefrontToken}` }),
fetcher: fetchSafe,
</file context>
| endpoint: `${checkoutUrl}/graphql`, | |
| endpoint: new URL("/graphql", checkoutUrl).href, |
| //22e714b360b7ef187fe4bdb93385dd0a85686e2a | ||
| const storefront = createGraphqlClient({ | ||
| endpoint: "https://storefront-api.fbits.net/graphql", | ||
| endpoint: `${checkoutUrl}/graphql`, |
There was a problem hiding this comment.
P2: The checkoutApi on line 117 defensively falls back to a default URL with checkoutUrl ?? \https://${account}.checkout.fbits.store`, but the storefront GraphQL endpoint on the changed line uses ${checkoutUrl}/graphqlwith no fallback at all. IfcheckoutUrlis somehow empty, undefined, or resolves to an empty string at runtime, the storefront client will break — its endpoint would be/graphql` (a relative URL) instead of an absolute one.
Recommendation: apply the same fallback pattern used for checkoutApi, e.g., `\${checkoutUrl ?? `https://${account}.checkout.fbits.store`}/graphql` or normalize checkoutUrl once at the top of App().
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At wake/mod.ts, line 112:
<comment>The `checkoutApi` on line 117 defensively falls back to a default URL with `checkoutUrl ?? \`https://${account}.checkout.fbits.store\``, but the storefront GraphQL endpoint on the changed line uses `${checkoutUrl}/graphql` with no fallback at all. If `checkoutUrl` is somehow empty, undefined, or resolves to an empty string at runtime, the storefront client will break — its endpoint would be `/graphql` (a relative URL) instead of an absolute one.
Recommendation: apply the same fallback pattern used for `checkoutApi`, e.g., `` `\${checkoutUrl ?? `https://${account}.checkout.fbits.store`}/graphql` `` or normalize `checkoutUrl` once at the top of `App()`.</comment>
<file context>
@@ -109,7 +109,7 @@ For help: https://wakecommerce.readme.io/docs/storefront-api-criacao-e-autentica
//22e714b360b7ef187fe4bdb93385dd0a85686e2a
const storefront = createGraphqlClient({
- endpoint: "https://storefront-api.fbits.net/graphql",
+ endpoint: `${checkoutUrl}/graphql`,
headers: new Headers({ "TCS-Access-Token": `${stringStorefrontToken}` }),
fetcher: fetchSafe,
</file context>
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}/graphqlinstead of the sharedhttps://storefront-api.fbits.net/graphql, so requests go to the account’s checkout domain. No config changes needed; theTCS-Access-Tokenheader stays the same.Written for commit 1d03676. Summary will update on new commits.
Summary by CodeRabbit