Navigate back to the homepage

how to force Laravel to use https in URL and assets

April 5th, 2021 · 1 min read

Hello Friends 👋,

Welcome To Infinitbility! ❤️

using the URL() helper is great for creating full HTTP links, I use this for all links, when working locally HTTP is fine but when going Production you want to use https instead. Replace Your app\Providers\AppServiceProvider.php from below code using this code Laravel on production force helper to use https URL.

2namespace App\Providers;
3use Illuminate\Support\ServiceProvider;
4use Illuminate\Routing\UrlGenerator;
5class AppServiceProvider extends ServiceProvider
7 /**
8 * Bootstrap any application services.
9 *
10 * @return void
11 */
12 public function boot(UrlGenerator $url)
13 {
14 if (env('APP_ENV') !== 'local') {
15 $url->forceScheme('https');
16 }
17 }
18 /**
19 * Register any application services.
20 *
21 * @return void
22 */
23 public function register()
24 {
25 //
26 }

More tutorial form Laravel

  1. Yajra issue after install in laravel
  2. Laravel call function from another class
  3. laravel pagination with customization
  4. How to solve page expired error in laravel for webhooks, ajax, and form
  5. Laravel Model
  6. Laravel Clear cache, config, view and Routes
  7. how to force Laravel to use https in URL and assets

Thanks for reading…

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide



More articles from Infinitbility

Expiring Daemon because JVM heap space is exhausted In React Native

how to solve jvm heap space issue in react native

April 4th, 2021 · 1 min read

gatsby build generating javaScript bundles failed

gatsby build failed issue with static folder path

March 31st, 2021 · 1 min read
© 2020–2022 Infinitbility
Link to $ to $ to $ to $ to $ to $mailto:[email protected]