How to enable HTTPS for local development in macOS using Chrome
HTTPS, macOS, Chrome
local HTTPS
https://www.cnblogs.com/xgqfrms/p/13582130.html
localhost & HTTPS
- 隐藏警告
- 修改证书
拖拽 icon
localhost.cer
Quit keychains, 刷新 Chrome
生成证书
key , cert 有效期
keytmp.pem
cert.pem
key.pem
$ openssl req -x509 -newkey rsa:2048 -keyout keytmp.pem -out cert.pem -days 365
# 123456
$ openssl rsa -in keytmp.pem -out key.pem
React 17 & SSR
{
"start": "HTTPS=true react-scripts start"
}
{
"start": "export HTTPS=true && SSL_CRT_FILE=cert.pem && SSL_KEY_FILE=key.pem react-scripts start",
}
demo
https://github.com/xgqfrms/react-in-depth/tree/master/https-app
key & cert
https://github.com/xgqfrms/react-in-depth/blob/master/https-app/cert.pem
https://github.com/xgqfrms/react-in-depth/blob/master/https-app/key.pem
https://github.com/xgqfrms/react-in-depth/blob/master/https-app/package.json
{
"name": "https-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-scripts": "3.4.3"
},
"scripts": {
"dev": "react-scripts start",
"start": "export HTTPS=true && SSL_CRT_FILE=cert.pem && SSL_KEY_FILE=key.pem react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
refs
https://flaviocopes.com/react-how-to-configure-https-localhost/
https://flaviocopes.com/macos-install-ssl-local/
https://medium.com/@jonsamp/how-to-set-up-https-on-localhost-for-macos-b597bcf935ee
https://dev.to/tability/local-development-with-https-on-osx-1jpb
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!