# Static IP for Vercel

Source: https://prontaro.com/docs/integrations/vercel/

Reach allowlisted payment gateways, partner APIs, and databases from a single fixed IPv4 without leaving Vercel.

By default, Vercel sends outbound traffic from ephemeral addresses that shift across deployments and regions. With Prontaro, you route only the calls that require a fixed IP: Node.js Functions use HTTPS proxy or SOCKS5, while Edge Runtime connects through a Relay URL.

## Which method to choose

Pick the method based on your Vercel runtime and destination:

| Vercel runtime | Prontaro method | End-to-end TLS / mTLS | Best for |
| --- | --- | --- | --- |
| **Node.js Functions** | HTTPS proxy (`undici` `ProxyAgent`) | Yes (HTTP CONNECT) | REST/GraphQL APIs, multiple hosts, mTLS |
| **Edge Runtime / Middleware** | Relay URL | No (TLS terminated on Prontaro server) | Edge routes without direct TCP sockets |
| **Node.js Functions → DB** | SOCKS5 (`socks5h://`) | Yes (driver TLS) | [MongoDB Atlas](https://prontaro.com/docs/integrations/mongodb-atlas.md), PostgreSQL, other TCP databases |

If a partner requires end-to-end TLS or mTLS, run that call in a Node.js Function over HTTPS proxy — see [Relay URLs](https://prontaro.com/docs/outbound/relay.md) for details.

## Prerequisites

- A Prontaro account on Dedicated or Pro ([plans](https://prontaro.com/docs/billing/plans.md)).
- A dedicated IPv4: open [my.prontaro.com/ips](https://my.prontaro.com/ips), pick a location near your Vercel region, and click **Add IP** (assigned when you pick a location, not at checkout).
- A Vercel project running Node.js 20+ (for Functions) or Edge Runtime.
- You do not need `prontaro CLI` for Vercel — create proxy credentials and Relay URLs directly in the dashboard.

## Step 1. Create credentials and allowlist your IP

Add your dedicated Prontaro IPv4 (`/32`) to the partner API or database IP allowlist.

### Path A. Proxy credentials for Node.js Functions

1. Open **IP addresses** in [my.prontaro.com](https://my.prontaro.com/ips), select your IP, and click **Create proxy credentials**.
2. Name the credential set (for example, `vercel-prod`) and copy the `HTTPS` URL (`https://u_vercel:s3cr3t@<entry>.prontaro.io:443`).

IP addresses Proxy credentials [Open in dashboard](https://my.prontaro.com/ips)

Wait until Step 5 before locking down the **To** destination list so the `api.ipify.org` check in Step 4 succeeds.

### Path B. Relay URL for Edge Runtime and Middleware

1. Open **IP addresses** in [my.prontaro.com](https://my.prontaro.com/ips), select your IP, and click **Add relay address**.
2. Enter the target host `api.example.com` and copy the generated URL (`https://relay-3f9c2a7e-5b1d-4c8a-9e60-1d2b3c4d5e6f.prontaro.run`).
3. Optionally open the Relay’s **Access** tab and add a password — the dashboard gives you a `Prontaro-Relay-Auth` header so it never collides with the upstream `Authorization` header.

IP addresses Relay address [Open in dashboard](https://my.prontaro.com/ips)

## Step 2. Add Environment Variables in Vercel

Store the credentials in the Vercel dashboard (or via `vercel env add PRONTARO_PROXY_URL production`). Turn on **Sensitive** to hide the value in the UI after saving, and select the target environments (Production, Preview, Development).

**Project → Settings → Environment Variables**

- `PRONTARO_PROXY_URL`: `https://u_vercel:s3cr3t@<entry>.prontaro.io:443`
- `PRONTARO_RELAY_URL`: `https://relay-3f9c2a7e-5b1d-4c8a-9e60-1d2b3c4d5e6f.prontaro.run`

> **Never use the NEXT_PUBLIC_ prefix**
>
> Variables prefixed with `NEXT_PUBLIC_` are bundled into browser JavaScript and expose your proxy password to every visitor. Keep `PRONTARO_PROXY_URL` and `PRONTARO_RELAY_URL` server-only.

- **Separate Production and Preview:** create a second credential set (`vercel-preview`) for Preview deployments so revoking or editing Preview rules never affects Production.
- **Redeploy after saving:** Vercel injects new environment variables only into fresh deployments.

## Step 3. Send requests through your static IP

The examples below use standard framework-agnostic Vercel Functions (`api/*.mjs`). The same `ProxyAgent` and `fetch` pattern works in Next.js App Router (`app/api/.../route.ts`), Pages Router, Astro, Nuxt, and SvelteKit.

### Node.js Functions (`undici`)

Install `undici`:

```bash
npm install undici
```

Instantiate `ProxyAgent` once at module scope so reused containers keep connections open:

```js
// api/partner.mjs
import { fetch, ProxyAgent } from 'undici';

const proxyUrl = process.env.PRONTARO_PROXY_URL;
const proxyAgent = proxyUrl ? new ProxyAgent(proxyUrl) : null;

export default async function handler(req, res) {
  if (!proxyAgent) {
    return res.status(500).json({ error: 'PRONTARO_PROXY_URL is not configured' });
  }

  const upstream = await fetch('https://api.example.com/v1/status', {
    method: 'GET',
    dispatcher: proxyAgent,
    headers: {
      Authorization: `Bearer ${process.env.PARTNER_API_TOKEN}`,
    },
    signal: AbortSignal.timeout(15_000),
  });

  const body = await upstream.text();
  res.status(upstream.status);
  res.setHeader('content-type', upstream.headers.get('content-type') ?? 'application/json');
  return res.send(body);
}
```

### Edge Runtime and Middleware (Relay URL)

Edge Runtime cannot open direct TCP sockets or HTTP CONNECT tunnels, so pass your Relay URL as the base URL to built-in `fetch()`:

```js
// api/edge-partner.mjs
export const config = { runtime: 'edge' };

export default async function handler() {
  const relayBase = process.env.PRONTARO_RELAY_URL;
  if (!relayBase) {
    return Response.json({ error: 'PRONTARO_RELAY_URL is not configured' }, { status: 500 });
  }

  const headers = {
    Authorization: `Bearer ${process.env.PARTNER_API_TOKEN}`,
    // If you enabled a Relay password:
    // 'Prontaro-Relay-Auth': process.env.PRONTARO_RELAY_AUTH,
  };

  const upstream = await fetch(new URL('/v1/status', relayBase), {
    method: 'GET',
    headers,
    signal: AbortSignal.timeout(15_000),
  });

  return new Response(await upstream.text(), {
    status: upstream.status,
    headers: { 'content-type': upstream.headers.get('content-type') ?? 'application/json' },
  });
}
```

## Step 4. Verify the outbound IP

Add a temporary route that calls `https://api.ipify.org?format=json`:

- **For Node.js Functions** (using `PRONTARO_PROXY_URL`):

```js
// api/egress-check.mjs (remove after verifying)
import { fetch, ProxyAgent } from 'undici';

const proxyAgent = new ProxyAgent(process.env.PRONTARO_PROXY_URL);

export default async function handler(req, res) {
  const r = await fetch('https://api.ipify.org?format=json', {
    dispatcher: proxyAgent,
    signal: AbortSignal.timeout(10_000),
  });
  return res.status(r.status).json(await r.json());
}
```

- **For Edge Runtime:** create a temporary Relay for `api.ipify.org`, save it in `PRONTARO_TEST_RELAY_URL`, call `fetch(process.env.PRONTARO_TEST_RELAY_URL)`, and delete that Relay afterwards in the dashboard.

Deploy and invoke the test route:

```
 
{"ip":"203.0.113.10"}
```

Confirm the address matches your IPv4 in [my.prontaro.com/ips](https://my.prontaro.com/ips), then delete `api/egress-check.mjs`.

## Step 5. Lock down allowed targets (recommended)

Once verified, restrict your proxy credentials to the exact destination host and port so leaked credentials cannot reach anything else:

1. Open **IP addresses → Proxy credentials** in [my.prontaro.com](https://my.prontaro.com/ips), select `vercel-prod`, and switch to **Access**.
2. Add `api.example.com:443` under **To** and save.

IP addresses Proxy credentials Access [Open in dashboard](https://my.prontaro.com/ips)

## Vercel notes and limits

- **Keep `ProxyAgent` at module scope.** Creating `new ProxyAgent(...)` inside the handler disables keep-alive and exhausts sockets under traffic spikes.
- **Match regions.** Check your region in **Project → Settings → Functions → Function Region** and pick the closest available Prontaro location in the dashboard.
- **Keep timeouts below `maxDuration`.** Set `AbortSignal.timeout(...)` shorter than your Function `maxDuration` so slow upstream APIs return a clean error instead of a hard platform timeout.

## Common errors

| Error | Cause | Fix |
| --- | --- | --- |
| `The edge runtime does not support Node.js 'net' module` | `undici` `ProxyAgent` imported in a route with `runtime = 'edge'`. | Switch to a Relay URL, or remove `runtime = 'edge'` to run on Node.js Functions. |
| `PRONTARO_PROXY_URL is not configured` on Preview | Variable enabled only for Production, or not redeployed after saving. | Enable the variable for Preview (with separate proxy credentials) and trigger a redeploy. |
| Function hits Vercel timeout (`504`) | Upstream call takes longer than `maxDuration`. | Set `AbortSignal.timeout(...)` below `maxDuration` and make sure your Prontaro location is close to your Vercel Function region. |

For proxy authentication and target errors (`407`, `403`, connection failures), see [error codes](https://prontaro.com/docs/cli/errors.md) and [HTTP & SOCKS5 proxy](https://prontaro.com/docs/outbound/proxy.md).

## Next steps

- [Connect to MongoDB Atlas](https://prontaro.com/docs/integrations/mongodb-atlas.md) — reach a MongoDB Atlas cluster over SOCKS5 with a static IPv4.
- [Relay URLs](https://prontaro.com/docs/outbound/relay.md) — how Relay URLs work, password protection, and Edge Runtime limits.
- [HTTP & SOCKS5 proxy](https://prontaro.com/docs/outbound/proxy.md) — HTTPS and SOCKS5 proxy setup and allowed destination rules.
- [Reliability, zero-downtime updates, and BGP failover](https://prontaro.com/docs/outbound/failover.md) — how your `/32` stays intact during server failover.
