← Posts

Fix HTTPS issue in the Statamic 3 Control Panel

July 29th, 2020

In the past, I've had issues when trying to use the Statamic Control Panel alongside using HTTPS. Usually, you'll get issues like the JS & CSS not loading or requests to the CP's API not working properly.

The good thing is.... it's an easy fix.

2021 Update: This issue commonly occurs when using Cloudflare with Statamic. The recommended way to resolve this issue is to use the Cloudflare Trusted Proxies package.

In the site's AppServiceProvider class (app/Providers/AppServiceProvider.php), add this into the register method:

1\Illuminate\Support\Facades\URL::forceScheme('https');

If you only want it to apply while in production you could add a little environment check like so:

1if (app()->environment() === 'production') {
2 \Illuminate\Support\Facades\URL::forceScheme('https');
3}

Hopefully that should sort the issues you're having!

Thanks for reading this post! If you found it helpful and want to read more like this, please consider sponsoring me.