The front-end development environment startup project changes the http protocol to the https protocol

Requirements, use navigator.mediaDevices.getUserMedia to call the mobile phone camera in H5, http cannot pass the security protocol

solution

one,

Publish to the service every time, this is too troublesome to adapt to development and debugging

2. Changing the development environment from http to https can be directly accessed, and can be opened in the mobile browser (WeChat browser is not allowed, but it doesn’t matter as long as the mobile phone’s own browser can be opened),

We look for the package.json file and find the scripts object in it. The scripts object contains our start-up packaging related instruction configuration, see the code

Put this code: HTTPS=true SSL_CRT_FILE=localhost+1.pem SSL_KEY_FILE=localhost+1-key.pem

Just copy it to the startup command

  "scripts": {
    "start": "cross-env HTTPS=true SSL_CRT_FILE=localhost+1.pem SSL_KEY_FILE=localhost+1-key.pem PORT=8009 UMI_ENV=dev umi dev",

  },

Expand PORT=8009, and PORT is the modification port number

Guess you like

Origin blog.csdn.net/weixin_46600931/article/details/127649163#comments_26913451