当前位置: 首页 > news >正文

uniapp 配置本地 https 开发环境(基于 Vue2 的 uniapp)

1、生成本地 HTTPS 证书(mac)打开终端,运行以下命令:

mkdir ~/ssl-cert && cd ~/ssl-cert

2、生成私钥:

openssl genrsa -out localhost.key 2048

3、生成自签名证书(有效期365天):

openssl req -new -x509 -key localhost.key -out localhost.crt -days 365 -subj "/CN=localhost"

项目目录里面会生成两个文件,分别是:

server.key

server.crt

4、配置 vue.config.js(用于 uniapp H5 模式)

在根目录下找到或者创建 vue.config.js,host:localhost(本地),host:‘0.0.0.0’(你的 ip)添加如下:

const fs = require('fs');
const path = require('path');module.exports = {devServer: {https: {key: fs.readFileSync(path.resolve(__dirname, 'server.key')),cert: fs.readFileSync(path.resolve(__dirname, 'server.crt'))},host: '0.0.0.0',port: 8080,open: true}
};

相关文章:

  • 【前端】使用HTTPS
  • Debian操作系统全面解析:从起源到应用
  • ARINC818_FILE
  • Nginx 安全防护与 HTTPS 部署实战笔记
  • Oracle 的V$LOCK 视图详解
  • nginx安全防护与https部署实战
  • GaussDB资源冻结与解冻:精细化资源管理的实践与策略
  • 《软件工程》第 7 章 - 软件体系结构设计
  • Android开机向导定制(1)开机向导加载流程
  • 《软件工程》第 15 章 - 软件度量与估算:从概念到实践​
  • opencvsharp usb摄像头录像 c# H264编码
  • Python 网络编程入门
  • MMA: Multi-Modal Adapter for Vision-Language Models论文解读
  • macOS烧录stm32程序初步成功
  • 海思3519V200 上基于 Qt 的 OpenCV 和 MySql 配置开发
  • Simple Factory(简单工厂)
  • 《软件工程》第 14 章 - 持续集成
  • C++——STL——unordered_map与unordered_set的使用以及使用哈希表封装unordered_map/set
  • DIY 自己的 MCP 服务-核心概念、基本协议、一个例子(Python)
  • ChatGPT 如何工作——提示工程、对话记忆与上下文管理解析
  • 北京通州做网站的公司/百度收录网站
  • 做网站wordpress/专业的seo外包公司
  • 优化网站设计有哪些方法/温州seo外包公司
  • 百度联盟广告关闭/百度seo排名360
  • 什么是手机网站建设/谷歌三件套一键安装
  • 专题网站开发 交互方法/免费seo教程分享