Reputation: 16565
I'd like to create a reverse proxy for my analytics so that it doesn't get shut down by ad blockers.
Cloudflare has an excellent API for this using their web-workers but using them in conjuction with a CNAME (i.e. on your own host) is only available on their enterprise plan.
The cloudflare code to do the reverse proxy is simply:
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
request = new Request(request)
var url = new URL(request.url)
url.hostname = 'api-js.mixpanel.com'
return await fetch(url, request)
}
How might one go about creating the same type of functionality using a Firebase function instead?
Upvotes: 0
Views: 712
Reputation: 1501
If you are specifically trying to proxy MixPanel requests to avoid Ad Blockers then you can do this via 2 methods
Upvotes: 1