How to force all URLs to follow HTTPS protocol not HTTP

519 0 0 0

Last Updated : 2024-04-16 14:45:50

In this snippet I will explain how to force all URLs in your website to follow HTTPS protocol not HTTP

Sometimes when deploying your website to live server, AJAX calls may have a conflict with HTTP protocols because all website URLs follow HTTPS protocol and other URLs in your website still follow HTTP protocol.

To Solve this, you have to force all website URLs to Follow HTTPS protocols in AppServiceProvider file use this code

use Illuminate\Support\Facades\URL;

* Bootstrap any application services.
* @return void
public function boot()
if(env('APP_ENV') != 'local') {

Mahmoud Anwar

Mahmoud Anwar

Back End Developer with a passion for developing innovative web applications that expedite the efficiency and effectiveness of organizational success. Well-versed in technology and writing code to create systems that are reliable and user-friendly. Also has the proven ability to motivate, educate, and collaborate effectively to build web applications and effectively track changes. Confident communicator, strategic thinker, and innovative creator to develop software that is customized to meet a company’s organizational needs, highlight their core competencies, and further their success.