apps/docs/content/troubleshooting/why-supabase-edge-functions-cannot-provide-static-egress-ips-for-whitelisting-3d78b0.mdx
When trying to establish secure connections from Supabase Edge Functions to external services, you might encounter difficulties with traditional IP allow listing. This guide explains why this problem occurs and provides various solutions to address it.
An Egress IP address is the public IP address from which network traffic originates when leaving a network or service. When an application or a serverless function connects to an external third-party service, the third-party service sees the connection coming from this Egress IP.
CIDR (Classless Inter-Domain Routing) is a method for efficiently allocating IP addresses and routing IP packets. It allows IP addresses to be grouped into blocks using a notation like [IP]/prefix_length (e.g., 192.168.1.0/24). Allow listing based on CIDR ranges typically grants access to all IP addresses within a specified block.
Supabase Edge Functions are serverless functions that run globally, close to your users, powered by Deno Deploy. They are designed for low-latency execution and adhere to "serverless" and "edge-first" principles:
Due to their serverless and globally distributed nature, Supabase Edge Functions do not originate from a single static IP address or a small, stable range of IPs. This prevents the assignment of fixed egress IP addresses necessary for traditional network-level allow listing.
Because Supabase Edge Functions lack static or stable egress IP addresses, standard outbound calls from an Edge Function to a service that requires IP allow listing (e.g., specifying an IPv4 CIDR range like [IP]/24) will likely be blocked.
This section details the approaches to enable secure connections from your Edge Functions.
This is the standard and recommended solution for connecting to third-party services that you do not control but which require a static IP address for allow listing.
If you own or control the destination server, you can shift your security strategy from the network layer to the application layer. Instead of relying on IP addresses for authentication, you use a shared secret.
supabase secrets set CUSTOM_AUTH_TOKEN=your_random_string).const token = Deno.env.get("CUSTOM_AUTH_TOKEN");).await fetch('https://api.example.com/data', {
method: 'POST',
headers: {
'X-Custom-Auth': token, // Example custom header carrying the secret
'Content-Type': 'application/json',
},
body: JSON.stringify({
data: 'example',
}),
})
This solution is for scenarios with extremely strict security policies (e.g., government or health data regulations) that might forbid the use of proxies or secret-based allow listing for compliance reasons.