Browser, build or function?
JavaScript in the browser calls APIs from the visitor’s connection. A pre-render step fetches data from Netlify’s build environment. A serverless function calls the API at runtime from Netlify’s function network. Allowlisting one of these does not cover the others.
If a request needs a private API key, move it into a function. Keep that function narrow: one that returns an order status, for example, not one that fetches any URL it is given.
Your options
- Netlify Private Connectivity: an add-on for Enterprise plans that also needs High-Performance Edge or High-Performance Build. Your account manager turns it on; Netlify then lists static IPs per function region (Ohio
cmh, Frankfurtfra, Londonlhr). It does not cover Edge Functions. - An authenticated HTTPS proxy: send only the function requests that need a fixed IP through your own server. Works on every plan when you control the HTTP client.
- A backend you already run with a stable outbound IP: let it make the call and protect the endpoint with authentication.
Option 1: Private Connectivity (Enterprise)
- Ask your Netlify account manager to enable it for functions, builds or both (they are separate).
- Open Team settings → General → Team details → Private Connectivity and copy the addresses for the function regions or builds you use.
- Set the site’s function region to
cmh,fraorlhrunder Cloud compute → Functions → Region, redeploy, and ask the API owner to allowlist every address for that region.
Option 2: use your own static IP from a function
- Log in to the client area, open My Services and click your server. Scroll to Use your IP from code, n8n, CI or a browser. Under Add a proxy user, type
netlifyand click Add.
You should see: a new card namedapp-netlify. Names can use letters and digits only, and MazeVPN adds theapp-prefix. - On that card, click Copy next to HTTPS proxy (marked Encrypted). The copied URL contains the password, so paste it only into a secret or environment variable, never into code.
The card of a new proxy user. The eye icon shows the password; Copy copies the full URL with the password. (Server IP replaced with an example.) You should see: a URL likehttps://app-netlify:…@203.0.113.42:443, where the address is your server’s IP. - In Netlify, open the project and click Manage in the top bar.
- Scroll to the section about how the app runs and click the Keys and secrets card, then Add a key.
- Name it
MAZE_PROXY_URL, tick Contains secret values, keep the Functions scope, paste the URL as the value for the live app and save.
Netlify now labels this page Keys and secrets (its docs still call it Environment variables). You should see: the key in the list with its value hidden. - Install undici (
npm install undici) and add a function that uses the helper. A variable set only innetlify.tomlis not available to functions at runtime, which is why it goes in the dashboard.// netlify/functions/partner-status.mjs import net from 'node:net'; import tls from 'node:tls'; import { fetch, ProxyAgent } from 'undici'; // For an HTTPS proxy addressed by IP, undici sends the IP as the TLS server name // and Node rejects it. Send a placeholder name and verify the certificate against the IP. function proxyAgent(proxyUrl) { const { protocol, hostname } = new URL(proxyUrl); if (protocol !== 'https:' || !net.isIP(hostname)) return new ProxyAgent(proxyUrl); return new ProxyAgent({ uri: proxyUrl, proxyTls: { servername: 'proxy.invalid', checkServerIdentity: (_name, cert) => tls.checkServerIdentity(hostname, cert), }, }); } const dispatcher = proxyAgent(process.env.MAZE_PROXY_URL); export default async () => { const res = await fetch('https://api.example.com/status', { dispatcher, signal: AbortSignal.timeout(10_000), }); return new Response(await res.text(), { status: res.status }); }; - Trigger a new deploy. Netlify applies changed variables only to new deploys.
Check the IP before you roll out
- For a quick check, temporarily point the same function at
https://ifconfig.me/ip, deploy a preview and open/.netlify/functions/partner-statuson it.You should see: your server’s IP, the Host shown in the client area. - Change the URL back, ask the API owner to add that single IPv4, then test the real request. You should see: a normal response instead of a 403 or timeout.
- Test every path that talks to the API, including scheduled functions, then remove old allowlist entries.
If it still fails
- Wrong IP? Some code path is not using the dispatcher, or the deploy does not have the variable (check the scope and deploy context).
- Right IP but a 401 or 403? Check the credentials and the allowlist entry with the API owner.
- Edge Functions do not run in the same network as serverless functions. Make the call from a serverless function.
Official references
- Netlify Private Connectivity for builds and functions
- Environment variables for Netlify Functions
- Netlify Functions overview
- Node.js Undici ProxyAgent
Skip the setup
A dedicated IPv4 in 38 cities, usually ready about 3 minutes after payment. Connect devices with WireGuard and apps with an authenticated HTTPS, HTTP, or SOCKS5 proxy. From $9.99/month.