Search code examples
phplaravellaravel-5

Why laravel redirects to https even in local environment?


I am working on Laravel version 5.5. I have one application that needs domain to execute. That's why, I added following entries in my /etc/hosts file so that I can open my application using domains like dashboard.application.dev or api.application.dev. Here is how my /etc/hosts file looks like.

127.0.0.1   localhost
127.0.1.1   p01ymath
127.0.0.1   dashboard.application.dev
127.0.0.1   api.application.dev

I am serving my application using php artisan serve --port=80 so that I can execute my application using plain development domain names. Yes, have turned off apache,nginx or any other server that runs on the port 80.

The issue is, when I try to open dashboard.application.dev or api.application.dev, It is getting redirected to https version of the application. I have cleared cache using php artisan cache:clear and composer dump-autoload and php artisan route:clear and php artisan optimize but nothing works.

Here is how my AppServiceProvider looks like. It says that if the application is not on the local environment, redirect to https version.

public function boot()
{
    if (!App::environment('local')) {
        URL::forceScheme('https');
    }
}

But my application is in local environment. My APP_ENV directive in .env file is set to local which means the application must not redirect me to https version. I even tried to clean cache on my browser and tried to open the application in another browser that I never use. Still, the issue remains unsolved.

Is there anything I am doing wrong?


Solution

  • Chrome 63 (out since December 2017), will force all domains ending on .dev (and .foo) to be redirected to HTTPS via a preloaded HTTP Strict Transport Security (HSTS) header. You can find more information about this here.

    Change domain to .local or .test