Open madsh93 opened 1 year ago
I'm not sure if my answer matches your question, but I'll try. I tried a solution, I think it can be called "proxy". Simply create an API that fetches the URL that needs to be "proxied" and in the script, call that URL.
An example from my experience with Axeptio : I created an API called Axeptio
// /server/api/axeptio
export default defineEventHandler((event) => {
return $fetch('https://static.axept.io/sdk.js')
})
And in my nuxt.config.ts
export default defineNuxtConfig({
app: {
head: {
script: [
{
innerHTML: `
window.axeptioSettings = {
clientId: "xxx",
};
(function(d, s) {
var t = d.getElementsByTagName(s)[0], e = d.createElement(s);
e.async = true; e.src = "/api/axeptio";
t.parentNode.insertBefore(e, t);
})(document, "script");
`,
type: 'text/partytown',
tagPosition: 'bodyClose',
}
],
}
},
...
And it works fine.
Hi
I'm looking to implement Facebook pixel. This requires a reverse proxy. Can this be done with Nitro? If that's the case I was hoping you'd be able to provide an example similar as to how you did with Plausible and GTM.