- Issue created by @abenbow
- π¬π§United Kingdom rattusrattus
Thought you might be interested in my learnings\development implementing proxies for PartyTown on client project to get around CORS issues..
I've been using API Proxy β along with the following PartyTown config:
const proxies = [ { base: 'https://bat.bing.com/', slug: 'bat-bing'}, { base: 'https://connect.facebook.net/', slug: 'fb'}, ]; if (proxy = proxies.find(proxy => url.href.startsWith(proxy.base))) { const uri = url.href.slice(proxy.base.length); return new URL(`https://drupal-sandbox.lndo.site/api-proxy/${proxy.slug}?_api_proxy_uri=${uri}`); } return url;
While API Proxy is a great module, I actually think that it's a bit overkill for just getting around CORS and if we included a proxy endpoint in the PartyTown module then we could accept the bases, as above, on the config form and inject them into the config via drupalSettings.
- πΊπΈUnited States abenbow Asheville, North Carolina
This is interesting! I didn't know this project existed, but I wish I had earlier. I've built proxies like this before, and it seemed like there should have been a pre-baked solution somewhere.
It looks like this is good for sites that can tolerate the extra API request on top of the existing page request, but I start to worry about sites with a lot of traffic (or a lot of tags that need to be proxied) and this API solution becoming a performance bottleneck. Do you have some notion of how this performs under load?
I do agree with you about it being a little overkill. It sort of feels like a network layer problem that the application layer is stepping in to solve. Ideally, your webserver could do this for you without Drupal getting involved. Of course, sometimes you just need a quick fix and Drupal is literally right there.
It could be a decent solution for folks who need something to launch PT fast.