Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of reverse proxy configuration #294

Open
madsh93 opened this issue Apr 29, 2023 · 2 comments
Open

Example of reverse proxy configuration #294

madsh93 opened this issue Apr 29, 2023 · 2 comments

Comments

@madsh93
Copy link

madsh93 commented Apr 29, 2023

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.

@Rekwian
Copy link

Rekwian commented Jan 18, 2024

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.

@muhsin-life
Copy link

please see QwikDev/partytown#647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants