BuilderIO / partytown

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

Can't get Partytown to work with anything (Google Maps, Hotjar, TrustPilot, ...) #93

Closed mryraghi closed 2 years ago

mryraghi commented 2 years ago

Hi everyone,

The vision of Partytown and the potential utility of this tool are noble and valuable.

However, after implementing it in a NextJs application, I quickly found myself covered with CORS issues. Both scripts loaded using GTM (Hotjar) and included in the <head> (Google Maps, TrustPilot, Sentry) seem to throw the same errors.

I've read the docs about reverse proxy and tried implementing it with Hotjar, but it doesn't seem to work either as it requires query params (which you can pass along ok), but it then makes other requests that are out of my control and ends up throwing CORS issues anyway. In addition, downloading and serving scripts from the same origin makes you lose new version updates (lousy security practice).

As of now, I fail to see the advantage of using this tool given the fact that:

  1. each script requires specific care and attention;
  2. you may not be able to have all scripts loaded using this strategy;
  3. if they end up working under a proxy or naturally, the value of GTM gets lost as non-dev can't add scripts autonomously (Google Optimize, etc.);
  4. (case-specific and in reply to custom Nginx configuration) I don't see this configuring neatly with Terraform and AWS ElasticBeanstalk, which provide incredible high-level cleanliness and organization in my cloud infrastructure.

In conclusion, since I recognize Partytown's potential, I'd like to ask if anyone has better solutions to get it to work in any other automated, out-of-the-box way. I've learned the hard way that too many patches and workarounds end up creating hidden issues and messing with the team's productivity and performance in the long term.

What are your thoughts?

Thanks!

adamdbradley commented 2 years ago

You need to use the reverse proxy as documented. Since this is more of a discussion it's better on discord and instead closing this issue. Thanks.