How to enable HTTPS for local development in macOS using Chrome


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

  1. 隱藏警告

  1. 修改證書

拖拽 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://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/

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

https://stackoverflow.com/questions/59080466/how-do-i-fix-my-ssl-configuration-for-local-development-with-apache



©xgqfrms 2012-2020

www.cnblogs.com 發布文章使用:只允許注冊用戶才可以訪問!



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM