本機開發時建議使用的 domain

本機開發時有個 domain 比較適當,可以避免一些奇怪的問題

透過 /etc/hosts 設定,自定的 domain

先說結論~
結尾一律用 .localhost 讓瀏覽器曉得這是本機用 domain

http://cola.localhost
http://my-project.localhost

本機開發時自定的 domain~
隨自己取都可以

http://cola.test
http://test.cola
...

不過! 在特定情況下使用特定格式的本機 domain 比較好!

在使用這個方法時,本機不 work~
(透過 js 將文字複製進使用者的剪貼薄)

需為 https 或瀏覽器准許之 domain

ref. Secure contexts - Web security | MDN

Locally-delivered resources such as those with http://127.0.0.1 URLs, http://localhost and http://.localhost* URLs (e.g. http://dev.whatever.localhost/), and file:// URLs are also considered to have been delivered securely.

Note: Firefox 84 and later support http://localhost and http://.localhost* URLs as trustworthy origins (earlier versions did not, because localhost was not guaranteed to map to a local/loopback address).

當然~ 實際情況還是得看瀏覽器支援

bonus: