by hackcrafter · 10y ago · 0 comments
I'm having a hard time conceptualizing what kind of logic you would run on these edge functions?
You have access to headers, so also things like client cookies, so could you use that to potentially personalize/templatize the body (once they have body mutation abilities)?
Or is it really just about static content routing? Detect google bot user agent and send them to resource A versus B etc...
Two use cases:
1) Routing Facebook and Twitter to a pre-rendered version of your single page app based on their user agents.
2) Adding custom headers to your responses, e.g. for a Content Security Policy.
There is no good way to do either of those things currently. You could have one off options for each of those and the 50 other common use cases, but this is actually a really elegant solution. Very well done.
And of course doing so at the edge means that you potentially shave off some latency during redirects.
I just recently used this model to host a JS widget used on external websites, now I could for example add some basic logic to disallow certain domains (by checking referrer headers) from using the widget.