Last active
December 28, 2024 21:50
-
-
Save eladmoshe/0ca3f60952a7c4c24ab9aa028e0873bf to your computer and use it in GitHub Desktop.
Script for linking a working certificate to create-react-app. Allows you to work with create-react-app and valid SSL certificate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# With create-react-app, a self signed (therefore invalid) certificate is generated. | |
# 1. Create some folder in the root of your project | |
# 2. Copy your valid development certificate to this folder | |
# 3. Copy this file to the same folder | |
# 4. In you package.json, under `scripts`, add `postinstall` script that runs this file. | |
# Every time a user runs npm install this script will make sure to copy the certificate to the | |
# correct location | |
TARGET_LOCATION="./node_modules/webpack-dev-server/ssl/server.pem" | |
SOURCE_LOCATION=$(pwd)/$(dirname "./local-certificate/server.pem")/server.pem | |
echo Linking ${TARGET_LOCATION} TO ${SOURCE_LOCATION} | |
rm -f ${TARGET_LOCATION} || true | |
ln -s ${SOURCE_LOCATION} ${TARGET_LOCATION} | |
chmod 400 ${TARGET_LOCATION} # after 30 days create-react-app tries to generate a new certificate and overwrites the existing one. | |
echo "Created server.pem symlink" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
looks like it won't work any more with webpack dev server v4 - can you please suggest how we can with v4.