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

AhmedRagab's avatar

Not secure after deployment my laravel apps

Hello guys, I have a problem which confusing and disappointing me . The problem is: after finishing a laravel app and deploying it , everything works fine except for the non secure mark that appears with the url. I tried so many solution but I haven't figured it yet. I tried forcing the http to https from my laravel app but It doesn't work and I also tried to use SSL certificate from my hosting and actually It didn't work aswell. I tried to deploy on different hosts and the problem appear with all of them and that leaded me that the problem in something in the development but I didn't find it out. I didn't upload my .env and I even set my APP_DEBUG variable to false while deployment. So please can someone try to help me to figure this out?

0 likes
14 replies
tjanuki's avatar

Hi @ahmed234 I experienced the similar problem as you.

In my case, some assets such as images and CSS files were loaded as http, which caused insecure marking.

Are you seeing any error messages in the browser console?

1 like
AhmedRagab's avatar

@tjanuki No I don't have anything in the console. I actually use S3 with AWS and I checked my images right now and they all are loaded via Https

Sinnbeck's avatar

Can you share a link so we can see the exact issue?

1 like
Snapey's avatar

@Ahmed234 OK so your heroku installation issues a redirect to http://

Your www.go-credit.xyz installation, the server certificate is for go-credit.xyz - not for www.go-credit.xyz

Entering https://go-credit.xyz instead, the request is redirected to http://

1 like
siangboon's avatar

i guess that you may need to purchase real SSL certificate from Digicert or any authorized certificate provider to be installed in the production server...

1 like
AhmedRagab's avatar

I remember that I once made a middleware to force the route to https and I used this middleware to the login form and when try to login it just redirects back with this error in my console:

Migrate entirely to HTTPS to have cookies sent to same-site subresources

but when i removed the middleware from the login route it works fine.

AhmedRagab's avatar

@Snapey I'm not using the default middleware by laravel which is TrustHosts. but I acturally use the csrf token in each form i have. Is that a problem?

AhmedRagab's avatar

@Snapey Thanks man I really apperciate your help , I debuged my middlewares and I found the problem.

mlhaus's avatar

I am using Laravel 11.42.1, and my Heroku app did the same thing. These were the changes I made to get it to work:

  1. Edit "app/Providers/AppServiceProvider.php" with this code:
<?php

namespace App\Providers;

use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        // Force HTTPS in non-local environments
        if($this->app->environment('production', 'staging')) {
            URL::forceScheme('https');
        }
    }
}
  1. Run this command in the terminal to create a new middleware class:
php artisan make:middleware TrustProxies
  1. Edit "app/Http/Middleware/TrustProxies.php" with this code:
  1. On Heroku, I set APP_ENV and APP_URL environment variables on my staging and production apps. I ensured the SSL certificate was created and working.

Please or to participate in this conversation.