@brandy
To run npm serve
with https, you can generate a self-signed SSL certificate and configure the serve command to use it. Here's a step-by-step guide:
1
|
openssl req -nodes -new -x509 -keyout server.key -out server.cert |
This command will generate a private key file (server.key
) and a certificate file (server.cert
).
1 2 3 |
"scripts": { "serve": "serve -s build -l 3000 --ssl-cert server.cert --ssl-key server.key" } |
This configuration tells the serve
command to serve the build
folder over HTTPS using the SSL certificate and key files you generated.
1
|
npm run serve |
Your application should now be running with HTTPS enabled.
Please note that using a self-signed SSL certificate may generate security warnings in the browser. For production applications, it's recommended to use a valid SSL certificate from a trusted Certificate Authority.