栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何通过create

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何通过create

在最新版本中,您应该设置环境变量来配置证书

SSL_CRT_FILE=.cert/server.crtSSL_KEY_FILE=.cert/server.key

create-react-app
不建议退出,因为您将无法无缝升级它。此外,您可以轻松获得有效的SSL证书而无需退出。
您将需要将证书复制到
node_modules/webpack-dev-server/ssl/server.pem
。缺点是您需要手动复制文件。但是,实现这种无缝连接的一种方法是添加一个
postinstall
创建符号链接的脚本。这是我创建的脚本:

#!/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 locationTARGET_LOCATION="./node_modules/webpack-dev-server/ssl/server.pem"SOURCE_LOCATION=$(pwd)/$(dirname "./local-certificate/server.pem")/server.pemecho linking ${TARGET_LOCATION} TO ${SOURCE_LOCATION}rm -f ${TARGET_LOCATION} || trueln -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"

package.json
应该看起来像:

"scripts": {    ...    "postinstall": "sh ./scripts/link-certificate.sh"}
  • 我的解决方案基于此线程


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/369181.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号