Netlify address for Next.js pre-rendering

I want to pre-render the homepage on my website The website is built with next.js. So I used getStaticProps to fetch the pricing plans. It works fine in development.

The problem is that the build fails because my backend is configured to only accept requests from domains matching a certain regular expression. I would like to know from what domain the API is being called during the build process so I can configure my backend to accept connections from that domain.

You could probably just determine this yourself.

In the same spot that you currently have the restriction you could log where you see the request coming from. If you’re concerned that it might be getting requested from multiple spots, just pass along a unique value from within the build which would let you precisely identify the Netlify requests.

Thanks for offering to help @nathanmartin . I would really like to explore your second approach but I have no idea where to begin.
I don’t know if it’s possible to manually set the request URL during the build process. Any pointers would be appreciated.

If I’m understanding correctly, your next.js based build makes a request to your backend.

If that’s the case, then you’ve presumably already “manually set the request URL during the build process”.

It would just be a case of adjusting that URL as needed, to either pass along a query string parameter you could use to identify the specific call, or even just create a new endpoint that it can call instead of the existing one.

1 Like

Hi, @chidimo. I also wanted to chime in and say that there is no client domain name sent in the request for an API. The request comes from a client IP address not a client domain name. That IP address might be resolvable to a domain name with a reverse DNS lookup but, even if this is true, it is likely just a domain name that is completely dynamic.

The IP address making the request is also dynamic. The IP address will not be the same over time. They are automatically assigned and will change frequently.

There is a feature request for the build system to use static IP address that are publicly documented but I cannot promise if that feature will ever become available.

To summarize, the IP addresses used by the build systems at Netlify for external requests are never guaranteed at this time. One workaround for this is to put some secret token in a request header and filter the API calls based on that header rather than the IP address or the domain it resolves to using a reverse DNS lookup. For example the build system uses the Google Compute Cloud (GCP) at this time (which can change). So, if my IP address was (just an example as that isn’t a public IP address), the the reverse lookup might be this: This is because the reverse lookup turn the IP address backward as subdomains under

However, if you use a regex to allow then anyone using GCP could access your API. Limiting access based a secret key in the header (or some other non-public secret) is a better way to filter access when the IP address and domain name cannot be known in advance.

If there are other questions about this, please let us know.

EDIT: Changed the reverse lookup domain name to the correct GCP equivalent.

1 Like

Yes, you understood me correctly. @luke has given me a better perspective on the issue. I’ll have to explore some other way to go about this.

Thanks and happy holidays

Thanks for this, Luke. Looks like I need to look for another way around this.

Happy holidays.

1 Like