plausible
plausible copied to clipboard
Proxy through Nitro server
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.