Netlify Functions Request Limits with Astro API Endpoints

Hi guys,

I have a rather exotic “Problem”. I have built a DummyAPI service using Astro API endpoints that return some mock data. I host the app on Netlify, therefore every API request triggers a Netlify function. This leads to hitting Netlify’s function limits pretty quickly.

I already played around with a couple of solutions, like building a API Rate Limit, but that rate limit probably also triggers a Netlify function since it runs on the sam endpoint and just returns a 429.

Any of you got a idea how to possibly circumvent this? My last idea would be to just redirect the request to a Python API endpoint that I host somewhere else, but I’d rather solve the issue using Astro only.

EDIT: I probably found a solution @astrojs/netlify | Docs. Will report back if it works.

It would give you mixed results. There’s no way to guarantee a function is not invoked at all even with caching as the cache is local to each CDN node and the cache competes with over millions of other sites. If your API is requested frequently from a location, it might work, but if not, it might get dropped from cache from time to time.

You can use Edge Functions for the rate-limiting part as they’re relative cheaper than Functions, but it’s still an additional cost that you might or might not want to bear. In case you don’t wish to bear that, your option is to host it externally like you’ve mentioned.