How do I add https to yarn run?

15,614

Solution 1

The boilerplate uses a development server budo, so yarn start essentially runs budo dist. You can still pass options to it.

budo has no https option, but it does have an --ssl option for this purpose.

yarn start --ssl

Solution 2

Explained on docs:

    HTTPS=true npm start

or set it on scripts section of your package.json:

    {
      "start": "HTTPS=true react-scripts start"
    }

Solution 3

I will answer because any of these answers don't work for me! Its all copied of the internet, but doesn't works fine!

To run in HTTPS your react app follow the guide below:

First you don't need to put HTTPS=true in "start" tag, instead, you need in your VS Code terminal, for example, put set HTTPS=true

so, yarn start and it will run on https

This is the output running with https this is the output running with https

Setting on "start" script tag occurs an error like "HTTPS' is not recognized as an internal or external command, so, I followed this way.

After that I installed my certificate generated with mkcert tool

Share:
15,614

Related videos on Youtube

scottlittle
Author by

scottlittle

Data Scientist

Updated on June 04, 2022

Comments

  • scottlittle
    scottlittle almost 2 years

    I am trying to run a yarn server with

    $ yarn run start --https
    

    which starts a server, but with http not https. The --https option works for another project that I was working on, but not this one. I was wondering if I need to set something in package.json as well to enable https. For reference, this is the github project that I cloned and am using: https://github.com/googlecreativelab/teachable-machine-boilerplate.

    • Explosion Pills
      Explosion Pills about 6 years
      Try with --ssl
    • scottlittle
      scottlittle about 6 years
      thanks, that worked. feel free to make this an answer. And maybe add a little explanation of why --ssl works and --https does not.
  • scottlittle
    scottlittle about 6 years
    It creates an https server that I can use from localhost. But if I go to my local IP location, it refuses the connection. Again, I don't really understand why since it worked in another project.
  • Explosion Pills
    Explosion Pills about 6 years
    You may look into using a tool like ngrok if you need to access from outside of localhost