luizdepra / hugo-coder

A minimalist blog theme for hugo.
MIT License
2.65k stars 1.05k forks source link

Working with Plausible Analytics #875

Open realchandan opened 6 months ago

realchandan commented 6 months ago

Hello,

I recently tried integrating my self-hosted Plausible instance with my site, but I faced issues with the CSP.

I finally got it working, but I spent a few hours experimenting with another Hugo module and changing the server's response headers.

I didn't know much about CSP before. It would be helpful and time-saving if you could update the Plausible Analytics Guide to include that, in case of self-hosting, we also need to add the Plausible domain to connect-src and script-src.

connectsrc = [
  "'self'",
  "https://plausible.example.com",
]
scriptsrc = [
  "'self'",
  "'unsafe-inline'",
  "https://plausible.example.com",
]

image

It might not be obvious to everyone, but now that I know, I will be more careful. And thank you for this amazing theme!

luizdepra commented 5 months ago

Sure. We need to mention that using CSP is not necessary too. It's a choice.

I'm going to flag this issue, asking for contributions. Anyone could add an entry in the docs folder about it.