๐ Reverse proxy requests from basic NodeJS server w/ Fastify and Next.JS API handler.
This repo is to show a example of a reverse proxy to use with Partytown.
npm install && node fastify-reverse-proxy.mjscurl "http://localhost:3000/proxy?target=https://analytics.tiktok.com/i18n/pixel/static/main.MTc5M2Y0YjUwMQ.js"Should return the text/html from script. Now in the browser, you can test if not will trouble in CORS anymore:
fetch("http://localhost:3000/proxy?target=http://bat.bing.com/bat.js").then((r) => {
r.text().then((t) => {
console.log("text retrieved", t);
});
});- Return encoded data based on
content-encodingHeader - Return 401 for urls not included in a
allow listfor proxy