plausible icon indicating copy to clipboard operation
plausible copied to clipboard

Proxy through Nitro server

Open MickL opened this issue 5 months ago • 1 comments

I would like everything to be proxied as described in the docs:

https://<yourdomain.com>/js/script.js -> https://plausible.io/js/script.js
https://<yourdomain.com>/api/event    -> https://plausible.io/api/event

In Nuxt normally this can be done easily by use of Nitro route rules, I imagine the following would work:

nuxt.config.ts:

routeRules: {
    '/api/event': {
      redirect: 'https://plausible.io/api/event',
    },
},
plausible: {
    apiHost: '/', <-- This doesnt work
},

The problem is that I cant set the data-api property as it is required and describe in the docs:

<script defer data-api="/api/event" data-domain="website.com" src="/js/script.js"></script>

If I set apiHost to / it makes the call go to https:///api/event instead of /api/event. If this would be fixed I guess it would work as shown above.

MickL avatar Aug 31 '24 20:08 MickL