2

I have created a new react app using "create-react-app" and used

"HTTPS=true npm start"

to change to https. I had a simple page that says hello world, but the page would constantly refresh on iOS with Safari on my local host.

What could be causing that issue?

David Ramsdale
  • 113
  • 1
  • 5
  • 1
    Thanks for your question, David. In order to dig into this further we will need to know more about what your code does with the `HTTPS=true` environment variable. Can you show us the section of your code that deals with serving HTTPS content? Or if you are using a react boilerplate, which one? – MattC Mar 04 '19 at 03:51
  • Hey Matt, I am using the "create-react-app" boiler plate. I read that using that line of code would change the HTTP environment variable. – David Ramsdale Mar 04 '19 at 04:00
  • What's the output message in your console? – hankchiutw Mar 04 '19 at 04:43
  • And what is the reason for using HTTPS in development? I ask because in most cases development is done on localhost over HTTP and then when deployed in production you would switch to HTTPS. – MattC Mar 04 '19 at 04:47
  • @HankChiu the error I get in the console is: Failed to load resource: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.1.112” which could put your confidential information at risk. – David Ramsdale Mar 04 '19 at 05:04
  • @MattC I was using https because I was trying to access my phones camera and it wasnt originally working. After some googling people recommended the solution I used in my question. It then worked for everything else but iOS. – David Ramsdale Mar 04 '19 at 05:04
  • 1
    Looks like you are running into an issue where Safari is doing odd things because your self-signed HTTPS certificate is not valid. Simply setting `HTTPS=true` is not enough, you will also need to create a certificate that Safari iOS will trust. Here's a thread on generating the cert: https://stackoverflow.com/questions/41192491/how-can-i-provide-a-ssl-certificate-with-create-react-app. After that you will need to also transfer your certificate to the iOS device that you are testing with: https://apple.stackexchange.com/questions/123988/how-to-add-a-crt-certificate-to-iphones-keychain – MattC Mar 04 '19 at 05:19

0 Answers0