Hi fellas, I have a quick question can we define dynamic url for our netlify functions. So, that it is not tied to just certain subdomain or root domain. I want to trigger my edge function whenever users visit any url that has my domain.
I can see cloudflare has something called worker routes. Workers are very similar to netlify edge function as far as I understand. But, the cool thing is you can define routes(even dynamic routes with * wildcard) when to trigger this worker. The prerequiste to this is you delegate DNS nameservers to cloudflare.
I can see we can delegate DNS nameservers to netlify also but i cannot find anything similar to routes. Please point me in the right direction.
Hi @devnrj07! Simon from the Team working on Edge Functions here.
Netlify Edge Functions are defined in the context of a specific site, and with the path /*
they will be run for all requests to that site (see docs). A site can have multiple domains assigned (see docs). If you combine this, all your traffic going to one of site’s domains will be run through your edge function. Inside the edge function, you can use request.url
to look up which domain was used.
Does that help solve your usecase?
Hey @skn0tt Thanks for the quick reply. I don’t think that’ll work in my case. My idea is to point apex domain to edge function and then subdomains will point to their own websites or web servers. For ex. blogs.mydomain.com → could be a wordpress site, aboutus.mydomain.com, → could be plain html app.mydomain.com → could be a react-app hosted on github. etc.
I want my edge function to get triggered whenever there is mydomain.com
in the request.url. Hence, the worker route thing *.mydomain.com/* this will match anything like blogs.mydomain.com.
Hi @devnrj07,
That’s currently not supported but we can add that as a feature request. We’ll let you know if something changes in this area.
That would be great. Thanks