0

I need to run "serve -s build" with https in reactjs application.

Try to run HTTPS with Npm and it is worked fine but when run production build using"serve -s build" the production run with HTTP not HTTPS.

serve -s build

A.Sh
  • 23
  • 5

2 Answers2

1

You must pass ssl information and the switch operate automatically.

openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
# Fill all prompted demands, "127.0.0.1" as "Common name" is OK for development environment
serve -s build --ssl-cert cert.pem --ssl-key key.pem

See also

psychoslave
  • 2,783
  • 3
  • 27
  • 44
0

Try using serve-https instead.

And if you are testing it in localhost in the Google Chrome you can enalble Allow invalid certificates for resources loaded from localhost. in chrome://flags/

UPDATE

serve-https seems unmaintened and its homepage git.daplie.com/Daplie/serve-https is not accessible at the time this post is written. – psychoslave

Abdulbosid
  • 354
  • 1
  • 2
  • 12
  • 1
    serve-https seems unmaintened and its homepage https://git.daplie.com/Daplie/serve-https is not accessible at the time this post is written. – psychoslave Jan 06 '23 at 10:13