How to fix Zaraz with Workers

For Workes & Pages, what is the name of the domain?

What is the error number?

404

What is the error message?

Not Found

What is the issue or error you’re encountering

Zaraz is trying to load from origin instead of from Cloudflare

What steps have you taken to resolve the issue?

  • Tried to modify Zaraz request from Workers, but not able to do it

What are the steps to reproduce the issue?

  • Open fyndx.io
  • Check the document and see r.referrerPolicy = "origin"; which is causing 404
  • This doesn’t happen with rocket-loader

Screenshot of the error

Seems to happen because your code has <base href="https://publish.obsidian.md> in it, making the browser construct the URL wrongly. Can you change that? Every relative URL you will include on your site will be parsed this way.

I don’t have much control over Obsidian Server Code, that’s the reason why I am trying to use Zaraz to inject some scripts.

Would it be possible to remove referrerPolicy origin in Zaraz??

Or is it possible to modify the HTML after Zaraz is injected, so I can use Workers to remove referrerPolicy??

<script defer="" referrerpolicy="origin" src="/cdn-cgi/zaraz/s.js?z=JTdCJTIyZXhlY3V0ZWQlMjIlM0ElNUIlNUQlMkMlMjJ0JTIyJTNBJTIyRGlnaXRhbCUyMEdhcmRlbiUyMC0lMjBGeW5kWCUyMiUyQyUyMnglMjIlM0EwLjgyODQ4OTI5Mjg0MTI4ODElMkMlMjJ3JTIyJTNBMTQ5NiUyQyUyMmglMjIlM0E5NjclMkMlMjJqJTIyJTNBNDc1JTJDJTIyZSUyMiUzQTE0NTQlMkMlMjJsJTIyJTNBJTIyaHR0cHMlM0ElMkYlMkZmeW5keC5pbyUyRiUyMiUyQyUyMnIlMjIlM0ElMjIlMjIlMkMlMjJrJTIyJTNBMjQlMkMlMjJuJTIyJTNBJTIyVVRGLTglMjIlMkMlMjJvJTIyJTNBLTMzMCUyQyUyMnElMjIlM0ElNUIlNUQlN0Q="></script>

Why do you think the issue has anything to do with the referrerPolicy ? I don’t think it’s related at all.

I believe that if you include a <script src="https://fyndx.io/cdn-cgi/zaraz/i.js"></script> tag in your code, the issue will be fixed. If you cannot add any HTML to your code, it’s going to be quite hard to support this. You can probably build a Worker that will include the above tag, however.