HTTP - GET only?! Third-party analytics want POST

Hi there,

Simple question: how can I integrate Zaraz with my existing 3rd-party tool RudderStack? Their HTTP source wants POST events, but the Zaraz HTTP “third-party tool” seems to want GET events.

Should I be using a different tool? Custom HTML doesn’t seem like a fit, but perhaps I’m missing something?

Cheers,

Ben

I can think of a work-around using a worker that receives the GET request, then forwards it as a POST… Let me see if I can get you a quick draft…

Try fiddling with this untested code:

addEventListener('fetch', event => {
    console.log("****** START ******")
  event.respondWith(getFinalResponse(event.request))
})

async function getFinalResponse(request) {

    //Request the URL
    console.log("Fetching the server's response...")
    
    
    const newRequest = new Request(request.url, {
        body: request.body,
        headers: request.headers,
        method: "POST",
        redirect: request.redirect
    })

    let response = await fetch(newRequest.url, request)
    console.log("Done.")
    
    return response
}

I had a look on the Discord (team is super active over there) but I can’t find anything about this. So, I’d recommend asking over there. Discord invite is: Cloudflare Developers

1 Like

You can now send POST requests with Zaraz :new: :new: :new: