Hi, folks! I believe I'm facing the same issue here and that A LOT of other developers out there are probably struggling with this to.
In my case, I have 3 Google scripts hugely affecting my pages performance score: Analytics (GTM), AdSense and GPT (Google Publisher Tag).
I've also decided to offload them to a WebWorker via Partytown.
AdSense and GPT, however, where 2 completely different beasts. For this to work, I had to setup a reverse proxy (which is the hard part and will depend on your tech stack).
2. On my webserver, the proxy reverses the URL to the original one and then requests it.
3. The proxy gets the response and sets the Access-Control-Allow-Orgin header to *.
4. The server sends the response to the client with the appropriate header getting rid of the CORS errors.
With this, I was able to get ad blocks from GPT to render properly and it seems to be working.
However, there's still one issue that I'm clueless as to what is causing it and what is its relevance. Not sure if I can ignore it (probably not):
I'm getting errors related to variables being undefined on the pubads_impl.js file.
My first guess would be that I still need to forward some function to the worker via the Partytown config, but I have no ideia what it would be.
The second one would be that maybe its due to the fact that I'm running this on my localhost and the script is simply lost and everything will be fine when I push this to production (but I wouldn't count on that).
Digging a little bit deeper, this errors seem to be related with the script trying to find script tags on the page, but since their running on the worker, they can't find it.
So, I'm a little lost as of where to go from here.