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.
I updated the issue. I think it would be possible if we could only set data-api property correctly
Would be even cooler if it is a simple proxy: true config option.
I added one comment to the PR, hope its okay if I dont open a new issue as it should be a quick fix :)