BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉
https://partytown.builder.io
MIT License
12.88k stars 427 forks source link

Integration of Cookiebot not working // http calls from within the script do not use resolveUrl. #387

Open rouvenst opened 1 year ago

rouvenst commented 1 year ago

Describe the bug I want to integrate Cookiebot (from UserCentrics, https://www.cookiebot.com/de/) into my Nuxt-App and make use of partytown. Installation works flawlessly. The reverse proxy works as well (thumbs up to your documentation). Reverse Proxy is implemented with Cloudflare functions.

The script of Cookiebot is added to nuxt.config.ts, therefore added to the<head> segment. With the resolveUrl script configured in nuxt.config.ts, the script is retrieved. Inside the Cookiebot script are references to other sites and scripts (bc-v4.min.html and cc.js). As they get fetched, the code of resolveUrl is ignored and direct calls against the Cookiebot site happen (e.g. https://consentcdn.cookiebot.com/sdk/bc-v4.min.html). This results in CORS errors making Cookiebot unusable.

Could relate to #243

To Reproduce Steps to reproduce the behavior:

  1. I've prepared an mwe to reproduce the error: https://github.com/rouvenst/nuxt-partytown-cookiebot
  2. Clone the repo
  3. npm install
  4. npx wrangler pages dev -- npm run dev (maybe install wrangler beforehand, https://developers.cloudflare.com/pages/platform/functions/local-development/)
  5. Visit http://127.0.0.1:8788/
  6. Reproduction link https://github.com/rouvenst/nuxt-partytown-cookiebot

Expected behavior Subsequent http calls from within a script which is loaded partytown should use resolveUrl to make use of the reverse proxy.

Partytown version 0.7.6 + "@nuxtjs/partytown": "^1.3.0"

Screenshots

image
kepi commented 10 months ago

Same problem, it would be great to have this working somehow.

I adapted @rouvenst code for our Qwik project and ended up in same dead end. I even tried to serve cookiebot scripts locally, modified code to rewrite urls for iframe too. In the end, it isn't working and I'm not sure how to proceed.

If you need help with testing, let me now. As for trying to find problem in partytown, I'm unfortunatelly out of my depth there.

I belive even some half-hack way would be better before it is possible to fix this properly.