0
0

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 3 years have passed since last update.

homesteadでngrok使う(style崩れる)

Last updated at Posted at 2020-11-15

#homesteadでngrokを使用しハマったこと

・mac
・Laravel   6
・homestead   9.6.1
・ngrok  2.3.35

vagrant sshでログイン
作業ディレクトリに移動

ターミナル
vagrant@homestead:~/code/app$ share homestead.test

これで作成されたURLでアクセスできる。

開発で使用しているPCではしっかりと表示されているが、URLをスマホに送り
スマホで見ると、CSS、画像などが反映されていない。

##原因
どうやら、asset関数が読み込まれていない。

hoge.blade.php
<link rel="stylesheet" href="{{ asset('/css/style.css') }}" />

これならしっかり反映される

hoge.blade.php
<link rel="stylesheet" href="css/style.css" />

しかし、トップページから違うページに飛ぶと、ページが表示されない
例(home => about)など

##解決法
vagrantではなくmacにngrokをインストールする

vagrant作業ディレクトリで

ターミナル
vagrant@homestead:~/code/app$ php artisan serve
Laravel development server started: http://127.0.0.1:8000

ターミナル 別タブ

ターミナル
hogehoge@hogehogeAir app % ngrok http 8000

生成されたURLに接続すればOK

これが正解か分かりませんが、これで上手く接続出来ます。

もっといい方法あれば教えてください。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?