使用 .test 字尾名解決 Chrome 強制跳轉 https 問題

Summer發表於2017-12-17

問題

《Laravel 入門教程》《Laravel 進階課程》 課程中,我們使用 .app 作為開發網站的字尾名,最新版的 Chrome 瀏覽器會強制 HTTPS ,具體原因 見此

不少同學已更新了 Chrome,導致 .app 字尾名無法訪問。

解決方案

解決方案現統一使用 .test 域名。按照以下操作即可:

1. 修改 Homestead.yml

> cd ~/Homestead
> atom Homestead.yaml 

查詢 .app 子串,修改為 .test ,並儲存。

2. 應用修改

應用配置資訊並重啟虛擬機器:

> cd ~/Homestead && vagrant provision && vagrant reload

3. 修改 hosts 檔案

Mac 下開啟 Hosts 檔案:

> atom /etc/hosts

Windows 下開啟 Hosts 檔案:

> atom C:/Windows/System32/Drivers/etc/hosts

同樣的,查詢 .app 子串,修改為 .test ,並儲存。

4. 加入到安全站點

《Laravel 進階課程》 課程中,我們使用 sudosu 外掛來輔助開發,Sudosu 有一個安全配置需要修改:

config/sudosu.php

<?php

return [

    // 允許使用的頂級域名
    'allowed_tlds' => ['dev', 'local', 'app', 'test'],

    // 使用者模型
    'user_model' => App\Models\User::class

];

allowed_tlds 裡增加 test 並儲存。

5. 開啟瀏覽器測試一下

開啟瀏覽器,注意第一次訪問的時候,需要加 http:// ,如 larabbs.test 應為 http://larabbs.test

file


Practice makes perfect.

相關文章