nuxt开启localhost的https测试环境

1,143 阅读1分钟

安装

yarn add path --dev
yarn add fs --dev

配置

在nuxt.conf.js顶部添加

import path from 'path'
import fs from 'fs'

添加到代码mode: 'universal',下方

server: {
  https: {
    key: fs.readFileSync(path.resolve(__dirname, 'cert.key')),
    cert: fs.readFileSync(path.resolve(__dirname, 'cert.crt'))
  }
},