0

I have laravel 5.6 site built in local, after running

php artisan serve

it shows Laravel development server started: http://127.0.0.1:8000, but when i enter this URL in browser it always redirect to https site, https://127.0.0.1:8000/login

I have check the followings:

1) in .env file environment is local

2) checked .htaccess file for redirection

3) checked middleware for if there is any redirection

What will be the problem?

arun
  • 4,595
  • 5
  • 19
  • 39

2 Answers2

1

You can use Laravels's ForceHttps Middleware to force https or http depending on the environment you're working on.

For example, I prefer to use HTTP on my local environment but to enforce HTTPS on the production environment.

In .env, set APP_ENV=local

Then, add the following in app/Providers/AppServiceProvider.php in the boot method.

       if($this->app->environment('production')) {
            \URL::forceScheme('https');
        }

You can also use:

    if (env('APP_ENV') === 'production') {
       \URL::forceScheme('https');
    }

Remember to always change .env on production environment to set APP_ENV=production

mutiemule
  • 2,319
  • 2
  • 28
  • 34
0

https issue solved by changing this:

'url' => env('APP_URL', 'https://localhost'),
//into
'url' => env('APP_URL', 'http://localhost'),

in your config/app.php file.

Inzamam Idrees
  • 1,955
  • 14
  • 28
  • checked APP_URL in both .env file and in config/app file, no https present there – arun Jan 04 '19 at 11:44
  • 1
    You can place this in the **AppServiceProvider** in the **boot()** method, or maybe create a ForceHttpsMiddleware: if($this->app->environment('production')) { URL::forceScheme('http'); } – Inzamam Idrees Jan 04 '19 at 11:57