12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel 本番サーバー上(production環境)だけhttpsにしたい

Last updated at Posted at 2018-02-20

困ったこと:
@assetではhttp://を向いてしまう

叶えたいこと:

local では http://
production では https://

を向いてほしい...
nginxの影響なのかhttpsを向いてしまうので困ってました

解決方法:
route/web.phpに以下を追加する

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

.envの APP_ENVproduction の時のみ URL::forceScheme を読んでくれる!

APP_ENV=production

環境:
local:
Laravel5.5 / PHP7.1
production:
Laravel5.5 / PHP7.1 / nginx

参考:
productionでhttpsにしたい
http://dolphin.hatenablog.jp/entry/2015/04/27/010635

12
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?