Cloudflare issue: panel tabs fetch over http

I have Kirby site behind Cloudflare that’s running fine, except whenever I click a tab the panel tries to fetch the api over http which fails due to CORS.

The url option in config.php is set to https + domain. Everything else (the front end, loading the panel, navigating to pages in the panel) is working fine. Checking the Kirby environment it indicates it’s working over https and isBehindProxy is true. The site is on Kirby 4.3.0 and PHP 8.2.6.

The TLS setup is ‘Flexible’, meaning traffic between Cloudflare and the site is over http so I suspect that has something to do with it, but I have no idea how to fix it.

Found the issue. The site was using some old Nginx config file I found online years ago and this directive:

# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename) {
    rewrite ^/(.+)/$ /$1 permanent;
}

… rewrote /panel/site/?tab=pages to /panel/site?tab=pages which caused the redirect over http.

Now that I’m writing this I vaguely remember encountering the same issue years ago :grin:

2 Likes

Thanks for posting this.

I also wasted a few hours figuring this out…

Yes thank you @phm, the panel said certain pages could not be found when I clicked on their tabs. It was due to this trailing slash handling in my .htaccess, which should probably be limited to frontend URLs:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]