Skip to content
Sections

Static IP for Cloudflare Workers

Call IP-allowlisted APIs directly from Cloudflare Workers with built-in fetch() — no npm dependencies and no proxy client required.

NeedsDedicated$12/mo$15A dedicated IP for your integrationsGet a dedicated IP

First payment refunded within 7 days if it doesn’t work for you

Cloudflare WorkersRelay URL
Static IPdedicated, only yours
  • Partner API
Partner API
On this page9

Cloudflare Workers run in V8 isolates across rotating Cloudflare IP ranges and cannot use traditional ProxyAgent or HTTP_PROXY libraries over direct TCP sockets. Instead, you bind a personal Relay URL (https://relay-<uuid>.prontaro.run) to the partner API host, store it with wrangler secret put, and let Prontaro forward each request from your dedicated static IPv4.

Why Relay URL is the right fit

Approach in Cloudflare Workers Works with built-in fetch() npm dependencies Outbound IPv4
Direct fetch() Yes None Rotating Cloudflare pool
HTTP CONNECT proxy No (no ProxyAgent over direct TCP sockets) — —
Prontaro Relay URL Yes None Your dedicated /32

Prerequisites

  • A Prontaro account on Dedicated (from $12/mo, 100 GB traffic) or Pro (plans) with a dedicated IPv4.
  • A Cloudflare Workers project with wrangler (npx wrangler).

Step 1. Create a Relay URL and enable Prontaro-Relay-Auth

Add your dedicated IPv4 (/32) to the partner API allowlist, then create a Relay URL bound to the partner host and protect it with a login and password.

The Prontaro server verifies and strips the Prontaro-Relay-Auth header before forwarding the request, so your upstream Authorization: Bearer ... header reaches the partner API untouched.

  1. Open IP addresses in my.prontaro.com and click Add relay address.
  2. Enter the target host api.example.com and copy the generated https://relay-....prontaro.run URL.
  3. Open the Relay’s Access tab, add a password named cf-worker, and copy the Prontaro-Relay-Auth value (<login>:<password>).
IP addressesRelay addressOpen in dashboard

Step 2. Save secrets with wrangler secret put

Store the Relay URL, Prontaro-Relay-Auth credentials, and partner API token as encrypted Worker secrets:

bash
npx wrangler secret put PRONTARO_RELAY_URL
# Paste: https://relay-3f9c2a7e-5b1d-4c8a-9e60-1d2b3c4d5e6f.prontaro.run

npx wrangler secret put PRONTARO_RELAY_AUTH
# Paste: cf-worker:s3cr3tPass

npx wrangler secret put PARTNER_API_TOKEN
# Paste: tok_partner_example

You can also set the same secrets in the Cloudflare dashboard:

Workers & PagesYour WorkerSettingsVariables and Secrets
PRONTARO_RELAY_URL
https://relay-3f9c2a7e-5b1d-4c8a-9e60-1d2b3c4d5e6f.prontaro.run
PRONTARO_RELAY_AUTH
cf-worker:s3cr3tPass
PARTNER_API_TOKEN
tok_partner_example

For local testing with npx wrangler dev, add these three variables to .dev.vars in KEY=value format (and keep .dev.vars in .gitignore).

Step 3. Call the API with standard fetch()

Zero npm packages required — construct new URL(path, env.PRONTARO_RELAY_URL) and send both headers:

ts
// src/index.ts
export interface Env {
  PRONTARO_RELAY_URL: string;
  PRONTARO_RELAY_AUTH: string;
  PARTNER_API_TOKEN: string;
}

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    if (!env.PRONTARO_RELAY_URL || !env.PRONTARO_RELAY_AUTH) {
      return Response.json(
        { error: 'PRONTARO_RELAY_URL and PRONTARO_RELAY_AUTH are required' },
        { status: 500 },
      );
    }

    // Path and query string are forwarded to https://api.example.com unchanged
    const upstreamUrl = new URL('/v1/status?env=prod', env.PRONTARO_RELAY_URL);

    const upstream = await fetch(upstreamUrl, {
      method: request.method === 'POST' ? 'POST' : 'GET',
      headers: {
        // Verified and stripped by the Prontaro server before forwarding
        'Prontaro-Relay-Auth': env.PRONTARO_RELAY_AUTH,
        // Reaches api.example.com untouched
        Authorization: `Bearer ${env.PARTNER_API_TOKEN}`,
        'Content-Type': 'application/json',
      },
      body: request.method === 'POST' ? await request.text() : undefined,
      signal: AbortSignal.timeout(15_000),
    });

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

Deploy the Worker:

bash
npx wrangler deploy

Step 4. Verify the outbound IP

To verify your Cloudflare Worker exits from your dedicated static IPv4, create a temporary Relay for api.ipify.org, call it from your Worker, and remove it right after:

  1. Open IP addresses in my.prontaro.com and click Add relay address.
  2. Enter the target host api.ipify.org and copy the generated temporary https://relay-....prontaro.run URL.
IP addressesRelay addressOpen in dashboard

Call new URL('/?format=json', relayIpifyUrl) from a temporary check route and invoke your deployed Worker:

curl -fsS https://your-worker.your-subdomain.workers.dev/egress-check
{"ip":"203.0.113.10"}

Confirm the address matches your dedicated IPv4 in my.prontaro.com, then delete the temporary Relay:

  1. Open IP addresses, find the temporary Relay for api.ipify.org, and click Delete.
IP addressesRelay addressOpen in dashboard

Cloudflare Workers notes and limits

  • Enable Smart Placement for lower latency: add [placement] mode = "smart" in wrangler.toml so Cloudflare runs your Worker closer to your Prontaro IP location and target API.
  • One Relay per target host (https://...:443): if your Worker talks to two partner domains, create two Relay URLs and store them in separate secrets (PRONTARO_RELAY_PAYMENTS, PRONTARO_RELAY_CRM).
  • HTTP/1.1 only: WebSockets and Upgrade requests are not supported over Relay URLs.
  • Fast rotation if leaked: add a new password login and delete the old one in the Relay’s Access tab, or delete and recreate the Relay under IP addresses, then update the secret with wrangler secret put.

Common errors

Symptom Cause Fix
401 or 407 from Relay Missing Prontaro-Relay-Auth header or trailing whitespace in the secret. Store PRONTARO_RELAY_AUTH as login:password using wrangler secret put.
Partner API returns 401 Unauthorized Used HTTP Basic in Authorization instead of Prontaro-Relay-Auth, overwriting the partner token. Send Relay credentials in Prontaro-Relay-Auth and keep the partner token in Authorization.
Cross-host redirect disappeared Relay strips the Location header pointing to another domain and adds Prontaro-Relay-Notice. Point your Relay at the final API host, or create a separate Relay for the second domain.
Secret is undefined in wrangler dev wrangler secret put only populates deployed Workers. Put local development values in .dev.vars at the project root.

Next steps

Contact us

Enter your email so we can reply.Enter a valid email, e.g. name@company.example.
Tell us what you need or what went wrong.up to 2,000 characters

Sent! We’ll reply to .

Or email us at support@prontaro.com