create-react-app: how to use https instead of http?

后端 未结 19 1125
眼角桃花
眼角桃花 2020-12-24 10:04

I was wondering if anyone knows how to use https on dev for the \'create-react-app\' environment. I can\'t see anything about that in the README or quick googling. I just wa

19条回答
  •  隐瞒了意图╮
    2020-12-24 11:05

    I`m using Windows 10 and I had the same issue. I realized that you need to:

    1. Run Command Prompt with Administrator Privileges
    2. Run on the terminal bash this command: set HTTPS=true&&npm start
    3. You can also put this code into your package.json file under the scripts section like this:

      "scripts": { "start": "set HTTPS=true&&react-scripts start", (...) }

    4. Bonus: If you want to change the PORT use this command insted:

      set HTTPS=true&&set PORT=443&&react-scripts start

      Obs.: Pay attention to the blank spaces NOT left in between some characters.

    You can browse this link for more detais.

提交回复
热议问题