Skip to content

feat(network policy): support header injections#53

Merged
robherley merged 6 commits intomainfrom
robherley/net-transform
Feb 20, 2026
Merged

feat(network policy): support header injections#53
robherley merged 6 commits intomainfrom
robherley/net-transform

Conversation

@robherley
Copy link
Contributor

Extends network policies to support transformers, with the current ability to inject custom headers.

const sbx = await Sandbox.create({
  networkPolicy: {
    allow: {
      "httpbin.org": [{
        transform: [{ headers: { "authorization": "Bearer my-secret-token" } }],
      }],
      "*": [{
        transform: [{ headers: { "x-foo": "bar" } }],
      }],
    },
  },
});

const f = async (url: string) => {
  const cmd = await sbx.runCommand("curl", ["-is", url]);
  console.log(await cmd.output());
};

await f("https://httpbin.org/get")
await f("https://echo.free.beeceptor.com")
Result
HTTP/2 200 
access-control-allow-credentials: true
access-control-allow-origin: *
content-type: application/json
date: Fri, 20 Feb 2026 01:30:13 GMT
server: gunicorn/19.9.0
content-length: 372

{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip", 
    "Authorization": "Bearer my-secret-token", 
    "Host": "httpbin.org", 
    "Transfer-Encoding": "chunked", 
    "User-Agent": "curl/8.15.0", 
    "X-Amzn-Trace-Id": "Root=1-6997b925-09eebe6f0730a9a3158e8b26"
  }, 
  "origin": "98.81.124.221", 
  "url": "https://httpbin.org/get"
}

HTTP/2 200 
access-control-allow-origin: *
alt-svc: h3=":443"; ma=2592000
content-type: application/json
date: Fri, 20 Feb 2026 01:30:14 GMT
vary: Accept-Encoding
via: 1.1 Caddy

{
  "method": "GET",
  "protocol": "https",
  "host": "echo.free.beeceptor.com",
  "path": "/",
  "ip": "98.81.124.221:63596",
  "headers": {
    "Host": "echo.free.beeceptor.com",
    "User-Agent": "curl/8.15.0",
    "Accept": "*/*",
    "Accept-Encoding": "gzip",
    "Via": "2.0 Caddy",
    "X-Foo": "bar"
  },
  "parsedQueryParams": {}
}

@vercel
Copy link

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandbox-cli Ready Ready Preview, Comment Feb 20, 2026 7:37pm
sandbox-sdk Ready Ready Preview, Comment Feb 20, 2026 7:37pm
sandbox-sdk-ai-example Ready Ready Preview, Comment Feb 20, 2026 7:37pm

Request Review

@robherley robherley merged commit 659c40e into main Feb 20, 2026
10 checks passed
@robherley robherley deleted the robherley/net-transform branch February 20, 2026 20:22
@github-actions github-actions bot mentioned this pull request Feb 20, 2026
robherley added a commit that referenced this pull request Feb 23, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## sandbox@2.5.0

### Minor Changes

- Add resource usage for stopped sandboxes.
([#54](#54))
    Add blocking mode for `stop` function.

### Patch Changes

- Update to use `@vercel/oidc@3.2.0` utilities, removing duplicate auth
logic and the local `JwtExpiry` class
([#34](#34))

- Updated dependencies
\[[`376a098243dddcee56c657b97856a0cd199113e0`](376a098),
[`46f0ed22f7128355942037321df70dc93481a50d`](46f0ed2),
[`659c40e719b21740024ede84c176257714f0086b`](659c40e),
[`35195578e5b5f68e7f9574b728ca7ff350bbad64`](3519557)]:
    -   @vercel/sandbox@1.7.0

## @vercel/sandbox@1.7.0

### Minor Changes

- Support passing private params in all API calls
([#52](#52))

- Add resource usage for stopped sandboxes.
([#54](#54))
    Add blocking mode for `stop` function.

- Adds transformers to network policy and support for header injections.
([#53](#53))

### Patch Changes

- Update to use `@vercel/oidc@3.2.0` utilities, removing duplicate auth
logic and the local `JwtExpiry` class
([#34](#34))

## sandbox-filesystem-snapshots@0.0.7

### Patch Changes

- Updated dependencies
\[[`376a098243dddcee56c657b97856a0cd199113e0`](376a098),
[`46f0ed22f7128355942037321df70dc93481a50d`](46f0ed2),
[`659c40e719b21740024ede84c176257714f0086b`](659c40e),
[`35195578e5b5f68e7f9574b728ca7ff350bbad64`](3519557)]:
    -   @vercel/sandbox@1.7.0

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rob Herley <rob.herley@vercel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants