LoginSignup
0
0

More than 1 year has passed since last update.

【heroku】デプロイ後に何も表示されない Mixed Content エラー

Posted at

Laravelで作成したアプリをherokuにデプロイ後、アクセスしても何も表示されませんでした。
コンソールを確認すると以下のようなエラーが出ていました。

Mixed Content: The page at 'https://appname.herokuapp.com' was loaded over HTTPS, 
but requested an insecure script 'http://appname.herokuapp.com/js/app.js'. 
This request has been blocked; the must be served over HTTPS.

中身を確認すると、src及びhref属性で読み込んでいるリンクが http:// になっており、これが原因と思われます。
エラー内容.png

エラー内容を検索したところ以下の記事を発見しました。
https対応したLaravelプロジェクトでassetを使う時の注意点

まさしく、ソースコードではassetを使用していました。

<script src="{{ asset('js/app.js') }}" defer></script>

そこで記事の回避方法の通り書き換えてデプロイし直したところ、無事アプリが表示されました。

TrustProxies.php
protected $proxies = '**';
AppServiceProvide.php
public function boot()
  {
      if (request()->isSecure()) {
          \URL::forceScheme('https');
      }
  }
0
0
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
0
0