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

tnort's avatar
Level 4

Laravel from insecure after deployment

Hi all,

Any idea why would the browser show as a page or form is insecure after deployment? I have checked a few posts here on Laracast and StackOverflow and I have checked the following issue:

-there is no env file public on the server -the app is in production mode and the debug option if set to false

Any idea what could be the issue?

0 likes
12 replies
Sinnbeck's avatar

Insecure how? Like no certificate in the browser or ?

1 like
tnort's avatar
Level 4

@Sinnbeck, apparently, it's a https connection.

the problem comes when I click on any form fields it says the connection is not secure and then sending the request the browser blocks it and asks me if I want to go back for allow the request.

Sinnbeck's avatar

Ah found the search field. That field has a http instead of https. Can you show the code for that form?

1 like
Sinnbeck's avatar

@tudosm Same problem. Show the code. Also make sure that APP_URL is using https

1 like
Sinnbeck's avatar

@tudosm Ok. Code?

And remember to redo your cache php artisan config:cache

1 like
tnort's avatar
Level 4

@Sinnbeck,

<form  
				method="GET"
				 action="{{ route('courses.index') }}" 
				id="navbarSearch" class="flex items-center">
                <input 	type="search"
								name="search" 
								class="border-0 fade-in border-b-2 w-72 border-black hover:border-0 focus:border-black focus:ring-0 hidden" 
								placeholder="search for course or university">
                <svg class="w-8 h-8 cursor-pointer hover:text-gray-400 ml-3" fill="none" 
								stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16l2.879-2.879m0 0a3 3 0 104.243-4.242 3 3 0 00-4.243 4.242zM21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
  @csrf
</form>
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@tudosm Try adding this to your AppServiceProvider (boot() method)

if($this->app->environment('production')) {
    \URL::forceScheme('https');
}
1 like
tnort's avatar
Level 4

@Sinnbeck,

that fixed the issue.

Thank you!!! Your help is highly appreciated!

Please or to participate in this conversation.