You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update docs for CORS proxy and Out-String wrapping
- CLAUDE.md: Add cors-proxy command, document proxy support in providers
section, add conventions for script wrapping and JWT audience override
- ARCHITECTURE.md: Move CORS proxy from future work to completed, add
Out-String wrapping and proxy to completed list, fix endpoint reference
-`bunx vitest run -t "test name pattern"` — Run tests matching a name
18
18
-`bun run test:spe` — Integration tests against a real SPE instance (separate config, 30s timeout)
19
19
-`bun run deploy` — Build + deploy to Cloudflare Pages via Wrangler
20
+
-`bun run cors-proxy -- --target <url> [--port 3001]` — Local CORS proxy for SPE Remoting
20
21
21
22
## Architecture
22
23
@@ -54,9 +55,13 @@ The codebase has two independent layers: a **pure TypeScript simulation engine**
54
55
55
56
**LocalProvider** — wraps the existing engine and virtual tree. Default for tutorials. Exposes `getContext()` and `getFullTree()` for validation.
56
57
57
-
**SpeRemotingProvider** — sends scripts to a real Sitecore instance via `speClient.ts`. Uses JWT or Basic auth. Tree panel falls back to virtual tree (SPE Remoting has no tree browsing API).
58
+
**SpeRemotingProvider** — sends scripts to a real Sitecore instance via `speClient.ts` (`/-/script/script/` endpoint). Uses JWT or Basic auth. Scripts are wrapped in `& { <script> } | Out-String` so PowerShell's ps1xml formatting rules apply server-side. Tree panel falls back to virtual tree (SPE Remoting has no tree browsing API). Supports optional CORS proxy (`useProxy`/`proxyUrl` in `ConnectionConfig`).
58
59
59
-
**ConnectionManager** component in the header lets users toggle between local simulation and a live Sitecore connection. URL and username persist to localStorage; credentials are never stored.
60
+
**ConnectionManager** component in the header lets users toggle between local simulation and a live Sitecore connection. URL, username, and proxy preferences persist to localStorage; credentials are never stored. Includes a "Use CORS proxy" checkbox for instances that block cross-origin requests.
61
+
62
+
### CORS Proxy (`tools/`)
63
+
64
+
**cors-proxy.ts** — Local Bun server that forwards requests to a Sitecore instance and adds CORS headers. Runs on the user's machine, so it can reach internal/VPN-only instances. Usage: `bun run cors-proxy -- --target https://sitecore.example.com`. The user enters `http://localhost:3001` as the proxy URL in ConnectionManager.
60
65
61
66
### UI (`src/components/`)
62
67
@@ -73,6 +78,8 @@ The codebase has two independent layers: a **pure TypeScript simulation engine**
73
78
-**Line continuation** — lines ending with `|` or backtick (`` ` ``) are joined before execution.
74
79
-**Execution goes through providers** — `App.tsx` never calls `executeScript()`/`executeCommand()` directly; it delegates to `providerRef.current`. New execution backends implement the `ExecutionProvider` interface.
75
80
-**Validation always runs locally** — `validateTask()` uses the local engine regardless of active provider, so lesson validation works offline.
81
+
-**SPE Remoting wraps scripts** — `speClient.ts` sends `& { <user script> } | Out-String` with `rawOutput=true` so ps1xml formatting applies server-side. Never send raw scripts without wrapping.
82
+
-**JWT audience uses real URL** — When using the CORS proxy, `audienceOverride` ensures the JWT audience targets the real Sitecore origin, not the proxy URL.
0 commit comments