【发布时间】:2020-11-08 15:11:51
【问题描述】:
在 VuePress 开发服务器中启用 https 有什么钩子吗?
1。当前解决方案。
我直接给node_modules/@vuepress/core/lib/node/dev/index.js加了一行。这很好用,但很讨厌。
createServer () {
const contentBase = path.resolve(this.context.sourceDir, '.vuepress/public')
const serverConfig = Object.assign({
https: true, // <--- Added this line.
disableHostCheck: true,
compress: true,
clientLogLevel: 'error',
2。背景
因为 Chrome 改变了它的安全策略,CORS。
3。我试过了。
- 我试过了,但没用。
docs/.vuepress/config.js
configureWebpack: (config, isServer) => {
if (!config.devServer) {
config.devServer = {}
}
Object.assign(config.devServer, {
https: true,
})
}
-
没有合适的钩子
-
没有 https 的命令选项。
module.exports = function (cli, options) {
cli
.command(`dev [targetDir]`, 'start development server')
.option('-p, --port <port>', 'use specified port (default: 8080)')
.option('-t, --temp <temp>', 'set the directory of the temporary file')
.option('-c, --cache [cache]', 'set the directory of cache')
.option('--host <host>', 'use specified host (default: 0.0.0.0)')
.option('--no-cache', 'clean the cache before build')
.option('--no-clear-screen', 'do not clear screen when dev server is ready')
.option('--debug', 'start development server in debug mode')
.option('--silent', 'start development server in silent mode')
.option('--open', 'open browser when ready')
.action((sourceDir = '.', commandOptions) => {
const { debug, silent } = commandOptions
4。相关链接。
【问题讨论】:
-
欢迎来到 StackOverflow 社区!似乎您已尝试自己格式化问题,这是..至少您尝试过。只需阅读这篇文章(stackoverflow.com/editing-help),它将帮助您将来处理 Markdown。并且不要忘记为提供有关您问题的有用信息的用户投票并将其标记为已解决。
-
复制一下,先生 :)
-
检查这个问题,会帮助你:stackoverflow.com/questions/45807049/…
-
Gabriel Willemann,感谢您的指导。