/sitecore-marketplace:marketplace-sdk-testing-debugfrom Sitecore Marketplace
Guides through local Marketplace app development: HTTPS setup with mkcert, test-app registration, Chrome Local Network Access, iframe sandbox limits, and auth/cookie debugging. Load during development and QA.
Ships in Sitecore Marketplace. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
For Client SDK reference (ClientSDK.init, base API patterns, extension points) see the marketplace-sdk-client skill.
For XMC endpoints see the marketplace-sdk-xmc skill.
For AI skills specifics see the marketplace-sdk-ai skill.
For auth model background see the marketplace-sdk-lifecycle skill, § 5.
Organization Admin or Organization Owner role1. Register a test app in Cloud Portal → App Studio
2. Configure dev URL → https://localhost:3000
3. Enable all extension points + all API access (for dev)
4. Install the test app into your SitecoreAI environment
5. Scaffold and run your app with HTTPS
6. Open from portal shell → your iframe loads the app
Detailed walkthrough of each step in the sections below.
Always register a separate app for testing, never repurpose the production app.
Prefix or suffix test apps so they can't be confused:
Test application — docs-recommended plain test app<Project> — DEV — per-project dev app<Project> — QA — per-project QA app| Field | Dev/QA value | Production value |
|---|---|---|
| App URL | https://localhost:3000 (or your dev tunnel URL) | Production HTTPS URL |
| Extension points | All — easier to switch contexts during dev | Only what you ship |
| API access | All — don't let permission errors confuse bug hunts | Minimized to what's used |
| User access | Only you — don't grant to org users | As appropriate for the release |
| Environment binding | A sandbox SitecoreAI environment | Production environment |
Rationale: a permissive test app removes an entire class of "why doesn't this work" questions. You can tighten permissions later when you register the production app.
Scope matters. HTTPS locally is only required for Scaffold 3 full-stack apps (or Mode B experimental_create*Client flows) where your app serves auth cookies at its own origin — those cookies carry SameSite=None; Secure and secure cookies cannot be set over HTTP.
Scaffold 2 client-side Mode A apps work fine over plain HTTP. The app sets no cookies at its own origin; auth is portal-brokered via postMessage. All you need on the client-side path is the Chrome Local Network Access headers (see references/https-traps.md § 3) — no HTTPS, no mkcert, no cert-trust dance.
If you're unsure: start on HTTP. Only flip to HTTPS (and accept the complexity below) when you hit "cookies not being set" in § 4 because your app owns an Auth0 server.
# Next.js 13.5+
next dev --experimental-https --turbopack
# Alternatives if you need a stable cert: mkcert, caddy, traefik in front of localhost
Set env:
APP_BASE_URL=https://localhost:3000
Post-scaffold dev-script patch (Scaffold 3 only): the shadcn quickstart ships next dev --turbopack without the --experimental-https flag. Edit package.json → scripts.dev to include --experimental-https before running against a real portal. Client-side Scaffold 2 apps keep the plain HTTP script and rely on the Chrome Local Network Access headers documented in references/https-traps.md instead.
Three failure modes bite when running an HTTPS dev server against the real Cloud Portal:
--experimental-https silently falls back to HTTP if mkcert -install can't elevate. Run mkcert -install from an elevated PowerShell, or pre-generate the cert manually.chrome-error://chromewebdata/ (Scaffold 3 only) — Chrome's click-through "Proceed Anyway" grants trust only for the exact top-level navigation, not for iframe subresource loads from a public origin. Either install the mkcert CA into the system trust store, or tunnel via cloudflared/ngrok for a public-CA-signed URL.localhost:* iframes are blocked unless the dev server advertises consent via Access-Control-Allow-Private-Network: true headers. Add the four-header block to next.config.mjs.For the full diagnostic walkthrough — symptoms, exact error messages in console, headers config, the * origin + credentials trap — see references/https-traps.md. The reference is the canonical one-stop debugging doc; the SKILL.md keeps just the rule + the pointer.
localhost)Add to your hosts file (/etc/hosts on Unix, C:\Windows\System32\drivers\etc\hosts on Windows):
127.0.0.1 myapp.local
Then use https://myapp.local:3000 in both APP_BASE_URL and the Cloud Portal dev URL. Certificate must cover the hostname — mkcert myapp.local is the quickest path.
In browser devtools → Application → Cookies → your app origin, cookies must have:
Secure column: yesSameSite column: NoneIf either is missing, the cookie config (see § 4) hasn't been applied.
Auth inside the iframe requires both session and transaction cookies to be cross-site compatible. Missing this is the most common cause of "login just doesn't work".
Required on session cookie AND transaction cookie:
{
sameSite: 'none', // allow cross-site
secure: true, // require HTTPS
}
import { Auth0Client } from '@auth0/nextjs-auth0/server';
export const auth0 = new Auth0Client({
session: {
cookie: { sameSite: 'none', secure: true }, // MANDATORY
},
transactionCookie: { sameSite: 'none', secure: true }, // MANDATORY — often forgotten
authorizationParameters: {
scope: process.env.AUTH0_SCOPE,
audience: process.env.AUTH0_AUDIENCE,
organization_id: process.env.SITECORE_ORGANIZATION_ID,
tenant_id: process.env.SITECORE_TENANT_ID,
},
});
| Symptom | Likely cause |
|---|---|
| Login redirect loops | sameSite: 'none' or secure: true missing on session cookie |
| Auth works outside iframe, fails inside | Transaction cookie not configured — only session cookie was set |
| Cookies appear then disappear on navigation | HTTPS not actually active (check cert in devtools) |
| "Organization not found" after login | organization_id missing from authorizationParameters |
401s on experimental_* calls even when logged in | Token audience mismatch — AUTH0_AUDIENCE must be https://api-webapp.sitecorecloud.io |
Mode B (experimental_createXMCClient / experimental_createAIClient — see the marketplace-sdk-lifecycle skill, § 4c) needs three values that aren't available at development time. Capture them post-install.
SITECORE_ORGANIZATION_ID=<id>SITECORE_TENANT_ID=<id>sitecoreContextIdapplication.contextresourceAccess[0].context.live (or .preview)// One-time capture snippet
const appCtx = await client.query('application.context');
console.log({
contextLive: appCtx.data?.resourceAccess?.[0]?.context?.live,
contextPreview: appCtx.data?.resourceAccess?.[0]?.context?.preview,
});
This capture step belongs in the implementation plan for any app using experimental mode — it is not automatic.
When something breaks in the iframe and you don't know where to start, work this list in order:
X-Frame-Options / CSP frame-ancestors errorsX-Frame-Options: DENY headers; set CSP frame-ancestors to include portal originClientSDK.init() handshaking?await ClientSDK.init({...})INVALID_ORIGIN: you passed a wrong origin option or target isn't window.parentHANDSHAKE_FAILED: app is loaded standalone, not in the portal iframe — open it from the portal shell, not directlySameSite=None; Secureauth0 / sitecorecloud.ioAPP_BASE_URL/auth/callbackAPP_BASE_URL misconfiguredaudience or organization_id wrong.data:
const result = await client.query('xmc.sites.listSites', opts);
console.log(JSON.stringify(result, null, 2));
isError: true + error.code tells you which error class (see the marketplace-sdk-client skill, § 8f)TOKEN_ERROR — auth config wrong; re-check § 4METHOD_NOT_FOUND — module not registered; pass modules: [XMC] or [AI] to initEXECUTION_ERROR — host-side failure; log error.message and contact Sitecore support if reproducibleSyntaxError: Unexpected end of JSON input / Failed to execute 'json' on 'Response': Unexpected end of JSON input on ai.skills.generateBrandReview → oversized base64 payload. Bridge or AI backend returns empty body → SDK JSON.parse throws. See the marketplace-sdk-ai skill, § 9f. Shrink or host-externally the uploaded file.client.subscribe(...) → always call unsubscribe() in React useEffect cleanup| Browser | Gotcha |
|---|---|
| Chrome / Edge | Most forgiving; most bugs reproduce here first |
| Firefox | Stricter cookie partitioning — validate here after Chrome works |
| Safari | Strictest. Third-party cookies in iframes often blocked by default. If your app must work in Safari, test there explicitly, not just Chrome. |
| Private / Incognito | Third-party cookies usually disabled → auth will fail. Not a bug — document this. |
Sitecore's Pages editor hosts Marketplace Context Panels inside an iframe with a restrictive sandbox= attribute. Know what is and isn't permitted before designing a capture / export / share flow.
The Pages iframe sandbox currently does not include allow-downloads. Any client-side download attempt from inside the panel will silently fail:
<a href="blob:..." download="file.png"> — the browser blocks the navigation triggered by the click; no file is saved, no error surfaces in the console.window.open(blobUrl) from inside the sandbox — same block.a.click() after constructing an anchor — same block.Sitecore has committed to adding allow-downloads soon. Expect this constraint to lift in a near-term Pages update. Until then:
Recommended workaround — escape the sandbox to a top-level tab:
window.open(blobUrl, '_blank', 'noopener,noreferrer');
This opens the blob URL in a top-level browser tab, outside the sandboxed iframe. The browser renders the PNG (or other resource) in the new tab and the user can right-click → Save Image As to disk. Requires allow-popups in the iframe sandbox — which IS present.
This is not a polished UX, but it's the only currently-working path to deliver a file from the panel to the user's disk. Track progress on the upstream sandbox fix and remove the workaround once allow-downloads ships.
allow-popups is present. window.open(url, '_blank', ...) works for:
Clipboard reads/writes (navigator.clipboard.writeText, navigator.clipboard.write(...) for binary blobs) are governed by the Permissions Policy (a separate browser gating mechanism), not the iframe sandbox. They require explicit user consent via the browser's permission prompt on first use, and they work independently of the download gate.
In practice this means: Copy (to clipboard) works inside the Sitecore Pages iframe today, even though Download (to disk) does not. A "Copy as PNG" or "Copy image to clipboard" button is a first-class path for moving content out of the panel until allow-downloads lands.
The browser silently drops Secure cookies. Symptoms look like "login doesn't persist" with no console errors. Always HTTPS from day one.
Browser caches cookies per origin. Two apps on https://localhost:3000 can interfere. Use different ports or hostnames (myapp-a.local, myapp-b.local) for parallel work.
Uninstall and reinstall when you change extension points or API access in Cloud Portal. The running iframe snapshots permissions at install time.
SitecoreAI environments aren't interchangeable. An app installed into dev-env-1 won't see content from dev-env-2. Verify the environment binding on the test app before blaming code.
During implementation planning: the plan must include: (a) HTTPS dev command (next dev --experimental-https), (b) full Auth0 cookie config block (§ 4a), (c) test-app registration values (name, URL, extension points, API access), (d) a runtime-value capture task if experimental mode is used (orgId, tenantId, contextId — § 5). All dev and validation runs against the registered Cloud Portal test app — there is no mock path. Do not treat HTTPS / cookies as "obvious" — they are commonly missed.
During testing: Test scenarios must cover (a) fresh install in a clean org, (b) re-install after extension-point changes, (c) login flow in Chrome and Safari, (d) Private/Incognito as a "should show clear error" scenario, (e) subscription cleanup on navigation. All tests run against the real portal. Add a validation spike if the app uses WebGL, eval, or any iframe-sensitive feature.
During implementation: Before reporting "it's not working", walk § 6 in order. Most iframe/auth failures are caught at steps 6b–6d — a 10-minute devtools check beats hours of trial-and-error.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub chris1415/sitecore-skills-pocs --plugin sitecore-marketplace7 skills in this plugin
/marketplace-sdk-aiAPI reference for @sitecore-marketplace-sdk/ai: module vs experimental client, generateBrandReview, payload traps, file inputs. Load when a Marketplace app calls AI skills such as brand review or content compliance./marketplace-sdk-clientAPI reference for @sitecore-marketplace-sdk/client: ClientSDK.init, provider patterns, query, mutate, subscribe, extension points, custom-field values, errors, test stubs. Entry point for any Marketplace app talking to the Cloud Portal./marketplace-sdk-extension-routesPost-scaffold step for a Marketplace app: pick Cloud Portal extension points, generate a Next.js App Router route for each, and produce the App Studio values. Use right after scaffolding or when adding an extension point./marketplace-sdk-host-frame-testingVisual testing of a Marketplace app inside its real host (Cloud Portal, Pages, Dashboard): find the app iframe, clip it, compare against the design. Use for visual or regression tests; a standalone localhost render is not enough./marketplace-sdk-lifecycleLifecycle of a Sitecore Marketplace app: custom vs public, Cloud Portal registration, client-side vs full-stack vs server-to-server architecture, Auth0, hosting, Blok, submission. Load before any code when planning a Marketplace app./marketplace-sdk-xmcAPI reference for @sitecore-marketplace-sdk/xmc: SitecoreAI endpoints (sites, pages, agent, authoring, preview, live, search), client modes, context id rules, response unwrapping. Load when a Marketplace app reads or writes SitecoreAI data.