Exclude path from Edge function based on query parameters

Hello,

Is it possible to exclude paths in our edge functions by query parameters? Here is a code example using the Config object.

export const config = {
  path: "/*",
  excludedPath: [
    "/*?skipEdgeFunction=true",
  ],
  method: "GET",
  cache: {
    browser: true,
    edge: {
      maxAgeSeconds: 3600,
      staleWhileRevalidateSeconds: 86400,
    },
  },
};

I have tried to put excludedPath: [ "/*?skipEdgeFunction=true"].

This doesn’t seem to work, is this possible? If not, is it possible to request it as a feature?

Thank you for your time,
Chris

No, it’s not possible. I don’t believe this would added as a feature any time soon (if at all), as we match based on the pathname and not the complete URL.

No problem. I think it could be a useful feature, but it’s obviously up to you guys if you want to introduce it.

Here’s my use case:

When someone hovers their cursor near a link on my MPA website, I preload it in the background ready for them if they click on it. Right now I have an authentication edge function running on every GET. I don’t want this edge function to run the authentication logic when I’m preloading a link and there doesn’t seem to be a config option to exclude it running when it’s being preloaded.

Kind regards,
Chris

Disappointing. I agree with @catholica’s statement:

Cloudflare has Functions routing which provides the ability to specify which paths to include and which to exclude from functions invocation.

For example you might want a function to run (almost) everywhere, excluding the site’s assests path for example

{
   "version": 1,
   "include": ["/*"],
   "exclude": ["/assets/*"]
}

Edit: This feature doesn’t support query parameters which was the original request. I don’t agree with excluding based on query parameters, but excluding based on path.

Hi Dig, you can exclude via path, just put it in the ‘excludedPath’ option in the Config

Oh yeah. Missed that bit in the documentation :man_facepalming:

1 Like