Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

craigwebster169's avatar

Force Inertia requests to use https

I'm trying to deploy Larvel 10.x and InertiaJS/React as a test app and the [::]:5173 GET requests are using http rather than https ... how do I change the protocol?

0 likes
9 replies
LaryAI's avatar
Level 58

To force Inertia requests to use HTTPS, you can modify the app/Providers/AppServiceProvider.php file in your Laravel application.

First, import the URL facade at the top of the file:

use Illuminate\Support\Facades\URL;

Then, within the boot method, add the following code:

public function boot()
{
    if (config('app.env') === 'production') {
        URL::forceScheme('https');
    }
}

This code checks if the application environment is set to "production" (you can change this condition to match your environment). If it is, it forces the URL scheme to be HTTPS.

Remember to import the URL facade at the top of the file and run composer dump-autoload to autoload the changes.

This will ensure that Inertia requests use HTTPS instead of HTTP in a production environment.

craigwebster169's avatar

The requests generated by the Client on initial page load are blocked because of mixed content, so they don't even reach the (Digital Ocean) Load balancer ...

phpmac's avatar

It is actually the trustProxies issue, which can be resolved by handling the middleware.

Please or to participate in this conversation.