If your development machine or production environment is behind a corporate firewall, outbound HTTPS requests to Uniform's API endpoints will be blocked. Your Next.js app will fail with errors like:
or:
Your app needs to reach two Uniform endpoints:
https://uniform.app — Management APIhttps://uniform.global — Edge Delivery APIThis guide covers how to route these requests through your corporate HTTP proxy.
The Uniform CLI is used under the hood even if you don't call it directly — for example, to download the Context manifest for personalization and A/B testing at app start.
Set the standard proxy environment variable before running any CLI commands or starting your app:
Replace http://your-proxy-server:8080 with your corporate proxy address.
Node.js does not automatically route fetch() requests through HTTP_PROXY/HTTPS_PROXY environment variables. You need additional configuration depending on which Next.js router you use.
The Uniform SDK clients accept a custom fetch parameter. Use https-proxy-agent to create a proxy-aware fetch wrapper and pass it to each SDK client.
Install the dependency:
Create a proxy-aware fetch function and pass it to Uniform SDK clients:
Repeat this for every SDK client in your app (e.g., CanvasClient, ContentClient, etc.).
The App Router uses Node.js native fetch() internally. You cannot pass a custom fetch function or agent to it, and Next.js overrides the global fetch dispatcher. The Next.js team has acknowledged this limitation.
The solution is to override globalThis.fetch in a Next.js instrumentation file, which runs when the server starts — before any page requests are handled. This patches all server-side fetch() calls to route external requests through your proxy.
Install the dependency:
Create instrumentation.ts in your src/ directory (or project root if you don't use a src/ directory):
Why this approach? Using
undici.setGlobalDispatcher()alone is not reliable because Next.js 15 overrides the global dispatcher internally. PatchingglobalThis.fetchdirectly and passing thedispatcheroption per-request ensures the proxy is used for all external requests. Theprocess.env.NEXT_RUNTIME === "nodejs"check prevents theundiciimport from being bundled into client-side code.
Note on Next.js 14 and earlier: Instrumentation is enabled by default in Next.js 15+. If you're on Next.js 14 or earlier, you may need to enable it by adding
experimental: { instrumentationHook: true }to yournext.config.ts.
How to run:
Note: If your corporate proxy performs SSL inspection (MITM), you may also need to trust the proxy's CA certificate:
export NODE_EXTRA_CA_CERTS=/path/to/corporate-proxy-ca-cert.pem
What | Page Router | App Router |
|---|---|---|
CLI proxy |
|
|
SDK proxy | Custom |
|
SSL inspection |
|
|
Variable | Purpose | Example |
|---|---|---|
| Proxy server URL for HTTPS requests |
|
| Proxy server URL for HTTP requests |
|
| Comma-separated list of hosts to bypass the proxy |
|
| Path to CA certificate for SSL-inspecting proxies |
|
To confirm the proxy is working, look for this log message when your app starts:
If you don't see this message, check that:
HTTPS_PROXY environment variable is set.instrumentation.ts file is in the correct location (src/ directory if your project uses one, otherwise project root).experimental.instrumentationHook: true in your Next.js config).