Edge Function Glob Pattern Matching

I’m currently trying to set up some simple pattern matching for the Netlify Edge Functions. Essentially I’m trying to ensure that various static folders don’t go through the edge functions, as it’s not necessary and dramatically increases the number of requests that will be processed.

I have this in the netlify.toml

path = "/!(assets|styles|js|locales)/**"

This works in multiple online glob matching tools, however everything is filtered out and nothing goes through the edge function when this is in place. I have to do path = "/*" in order for it to work.

Is there another way of getting certain folders ignored from edge functions?


You can try setting up redirects. You will be able to defines the folders that should be processed by the Edge Functions and ensures that other requests bypass the functions while explicitly defining the paths that should be processed by your function.

Thanks @SamO ,

The folder structure is dynamically created and there are hundreds of folders, so this wouldn’t this require hundreds of redirects? It’d be nice if the glob pattern matching was a little more advanced.

The documentation links to the ‘glob’ npm package documentation, which states you can use !(exclude|these|directories) but it appears that you can’t do anything but simple matching :thinking:

I don’t think you’re missing anything; I don’t believe you can use regexps like that in the path specs for edge functions.

So: you will likely need a lot of individual specs for this, today. I am not going to suggest you rearchitect your site to do this of course, but if you did have all your files in a few directories, it would make that easier: “run on /dynamic, but not on /static”.

I did pose the question into the dev team as to whether we have plans to support your use case more directly, and will let you know what they have to say!

Hey Nick - positive news! While the feature you want isn’t quite here yet, substantial work has already been done and a proof of concept is already working for our internal use. While I can’t promise a timeline, it sounded like not a ton of work was remaining. I’ll make a note to check back with the team in a few weeks to respond here in hopes of updated status and some docs I can point you to about using an excludedPath parameter.

Perfect, thanks @fool! Look forward to this feature’s release! :smiley: