cloudflare breaking my quartz navigation
I'm having an interesting issue with Cloudflare again, possibly once again due to Caching.
For context: My custom domain are handled through Cloudflare. I used to have an issue for a while where some of my blog pages didn't show my chosen font (which was hosted on Nekoweb at that time and imported into this blog from there). It would affect different pages for different people and the times where the correct font would or would not be shown was varied. The solution was that I needed to set a Cache Rule in Cloudflare Settings that bypasses cache on all requests from Nekoweb and Bearblog.
Now I'm having the interesting issue that if I use my Quartz site with custom domain disabled (no Cloudflare), the sidebar navigation works as expected and intended; but if I enable my custom domain (which makes it run through Cloudflare), the sidebar navigation duplicates upon navigating inside it and clicking around in it or going back to home. That means after just a few clicks, the sidebar content is there 3-5 times. It just gets appended to the bottom of it, repeating.
I'm assuming now the issue occurs because Cloudflare's optimization features can interfere with Quartz's SPA navigation system, which relies on specific timing of JavaScript execution and cleanup functions. The sidebar components use event listeners that need to be properly removed and re-added during navigation and when Cloudflare's optimizations alter the script execution, the cleanup mechanism may not work correctly.
I tried including it in my existing Cache rule, and even letting all requests bypass cache, but that didn't fix it. No Cloudflare optimizations (RocketLoader etc.) are enabled; many are a premium feature anyway.
Sigh, I used to need Cloudflare for custom domains on Nekoweb, but it hasn't been needed for a while; if I can't find a fix, I might move the domains back to Porkbun. For now I have disabled SPA in my Quartz layout.ts, but results in full page reloads after every click in the navigation and is a bit inelegant. Oh well.
If you have any ideas, let me know!
Reply via email
Published 26 Jun, 2025