Edge Functions: Negate Endpoints in netlify.toml

Hi All, currently configuring edge functions on our netlify app:

[[edge_functions]]
function = "eleventy-edge"
path = "/*"

The challenge I have here is that I’m runnign an API call (that we are charged for) within the edge function, currently it runs for every single page and asset request, including images and js files.

If there a syntax that I can’t find in the docs that would allow me to run for all paths except for these assets?

[[edge_functions]]
function = "eleventy-edge"
path = "/*!(.png|svg|js)"

or something like that?

The .toml definitely doesn’t support it, but I think you can use the advanced API: Create an Edge Functions integration | Netlify Docs

I understood that the manifest.json was auto-generated by netlify dev command, hence it adds the entire .netlify folder to the project’s gitignore automatically?

Yes, that is correct. When you run the netlify dev command, it automatically generates a manifest.json file in the .netlify folder. The .netlify folder also contains other configuration files and settings such as redirects, headers, and environment variables.

Thanks @SamO - in that case, with Edge Functions, is there anyway to do endpoint negation (i.e. prevent edge functions running on all image requests) given that the tomlz does not support this.

I’m not super familiar with that to be honest but I did find some documentation that might answer your questions.

  • Redirects Path-Based Routing: This section redirects documentation covers the syntax for path-based redirects and how to use negated patterns to exclude certain paths.

I hope that helps! Let me know if you have any further questions.