mac https本地跨域配置
本地開啟網頁服務的方法很多,一般借助emcc自帶的emrun命令 emrun --no_browser build 即可開啟本地http服務
最近在搞webassembly多線程,由于chrome在91版本之后如果要開啟對sharedarraybuffer的使用,需要對網頁配置跨域隔離,搜了網了有不少解決方案,我這邊試了兩個:
1、設置參數--disable-web-security,[yourname]換成電腦名稱,一般是admin,這種方法,雖然設置跨域成功了,但是sharedarraybuffer沒有啟用成功,有時間可以去研究一下
open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --user-data-dir=/Users/[yourname]/MyChromeDevUserData/2、 開啟https服務,注意不是http,兩者有些區別,本地開啟https是默認會開啟跨域隔離的,接下來就是研究如何開啟https服務,可以參考Using SSL in local developmenthttps://blog.revathskumar.com/2020/07/using-ssl-in-local-development.html
1)安裝AC證書
這一步使用mac的homebrew安裝,brew install mkcert
2)執行mkcert --install
3)執行mkcert localhos 127.0.0.1,這時候目錄下面會出現兩個localhost的pem的證書
4)執行python腳本啟用https服務
跨域服務參考資料:
Cross Origin Isolation:如何進行跨域隔離 - sky0014 - 博客園
https://github.com/sky0014/blog/blob/main/cross-origin-isolation.md
解決 SharedArrayBuffer is not defined - 掘金
https://segmentfault.com/a/1190000012550346
總結
以上是生活随笔為你收集整理的mac https本地跨域配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mac端addr2line的NDK位置和
- 下一篇: if三目运算符讲解