> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ns.rocks/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Preview Proxy Example

> Run a minimal customer-owned proxy in front of a Nullspace preview target.

Use a custom preview proxy when your application needs its own domain, auth
session, middleware, or WebSocket handling in front of a machine preview.

## Generate a target

```bash theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
nullspace machine preview-proxy-target create mch_123 8080 \
  --transport http --transport websocket --json
```

The response includes marker-only upstream URLs and transport-specific header
tokens. Store those token values in the proxy environment, not in browser code.

## Samples

* Node/Express: `examples/custom-preview-proxy/node-express`
* Python/FastAPI: `examples/custom-preview-proxy/python-fastapi`

Both samples forward `x-nullspace-preview-proxy-token` on every upstream
request, preserve the required forwarded headers, support WebSocket upgrades,
and optionally forward `x-nullspace-traffic-access-token` when private traffic
is enabled. They forward arbitrary subpaths and query strings so route refresh,
relative redirects, static assets, and file-server paths continue through the
same proxy.

## Related

* [Custom preview proxy](../networking/custom-preview-proxy)
* [Token model](../networking/token-model)
* [Preview URLs](../networking/preview-urls)
