Repository navigation
Description
The "Forward Matching Requests to a Proxy" section of the sandbox skill (skills/sandbox/SKILL.md, lines 638 to 674) was updated for @vercel/sandbox 5.0.0. Three things in it can mislead a reader.
1. It does not say which version it needs
The own-project rule and the allow option are new in 5.0.0, released on November 25. The skill describes them as if every version had them.
In 4.1.0 and earlier:
defineSandboxProxydoes not check the project at all. Any sandbox with a valid token can use the proxy.- The second argument is the invalid-request handler, not an options object:
defineSandboxProxy(handler, invalidRequestHandler?)(dist/proxy.d.tsin@vercel/sandbox@4.1.0).
So on 4.x, defineSandboxProxy(handler, { allow }) never calls allow. TypeScript reports a type error, but plain JavaScript runs without complaint, and the proxy stays open to every sandbox with a valid token.
Suggested text: "The own-project rule and allow need @vercel/sandbox 5.0.0 or later. Earlier versions accept any sandbox."
2. One case is missing
Line 673 says a proxy outside Vercel has no VERCEL_PROJECT_ID. A project on Vercel that has system environment variables turned off is in the same position: it rejects every sandbox with 403. The 5.0.0 changelog and the error message both mention this case.
Suggested text, from the changelog: "A proxy with no VERCEL_PROJECT_ID, such as one outside Vercel or in a project with system environment variables disabled, rejects every sandbox until it has an allow."
3. handler means two different things
In the first snippet (line 646), handler is the finished proxy: const handler = defineSandboxProxy(...). The second snippet (line 667) then calls defineSandboxProxy(handler, { allow }).
Read together, the second snippet wraps the proxy a second time. From reading proxy.ts, the outer proxy removes the forwarding headers before it calls the inner one, so the inner one would reject every request with "Missing required proxy headers". I have not run this.
Suggested fix: show the whole call in the second snippet with the handler written inline, or give the inner function its own name.
Found while syncing the sandbox skill into vercel/vercel-plugin (vercel/vercel-plugin#467).
Activity