如何修复这些 SockJS ssl 错误? [英] How can I fix these SockJS ssl errors?

查看:31
本文介绍了如何修复这些 SockJS ssl 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 vue-cli 3,我有一个 vue 应用程序在开发模式中呼啸而过.我调用 npm run serve,我看到了...

With vue-cli 3, I've got a vue app whirring away in development mode. I call npm run serve, and I see...

DONE  Compiled successfully in 431ms                                                                                                                                                                   
16:26:43
App running at:
- Local:   http://localhost:8080/mobileapp/v/
- Network: http://172.18.55.202:8080/mobileapp/v/

(路径/mobileapp/v/来自baseUrl配置变量.域notilusdev.dimosoftware.com/mobileapp指向iis中的一个vdir,对/mobileapp/v/的请求是反向代理到 webpack-dev-server)

(The path /mobileapp/v/ comes from a baseUrl config variable. The domain notilusdev.dimosoftware.com/mobileapp points to a vdir in iis, and requests to /mobileapp/v/ are reverse proxied to webpack-dev-server)

在浏览器中,应用程序启动没有问题.然后它开始向 https://172.18.55.202:8080/sockjs-node/info?t=1529072806971 发出请求.这些请求失败,因为该端口上没有 ssl.我什至不希望 ip 作为站点的公共地址.Webpack(或 sockjs)是如何构造这个 url 的?为什么当它只给我一个直接的 http 链接时,它认为这个端口上有 ssl?如果它基于地址栏协议的协议,为什么它会忽略地址栏主机名.我可以配置什么来使这些请求成功?

In the browser, the app fires up no problem. Then it starts firing off requests to https://172.18.55.202:8080/sockjs-node/info?t=1529072806971. These requests fail, because there's no ssl on that port. I don't even want the ip as the public address of the site. How does Webpack (or sockjs) construct this url? Why does it think there's ssl on this port when it's just given me a straight http link? If it's basing the protocol on the address-bar protocol, why is it ignoring the address-bar host-name. What can I configure to get these requests to succeed?

推荐答案

这是一场斗争,但现在正在奏效...

This was a struggle, but it's working now...

向 vue.config 中的 devServer 对象添加一个 public 属性.

Add a public property to the devServer object in vue.config.

我需要的属性是public,而不是publicPath,而且关键在于vue 会忽略configureWebpack{ devServer: { 中的配置更改>.您需要使用顶级 devServer 属性.

The property I needed was public, not publicPath, and the clincher was learning that vue will ignore config changes in configureWebpack{ devServer: {. You need to use the top level devServer property.

所以我的工作 vue.config.js 是...

So my working vue.config.js is...

module.exports = {
  baseUrl: process.env.NODE_ENV === 'production'
    ? '/production-sub-path/'
    : '\/mobileapp\/v\/',
    devServer :{
      public : 'notilusdev.dimosoftware.com',
      host : '0.0.0.0',
      disableHostCheck : true
    }  
}

然后我需要通过 express 反向代理 https 和 wss://请求,在 express 中终止 ssl,但那是另一回事了.

Then I needed to reverse-proxy https and wss:// requests through express, terminating the ssl in express, but that's another story.

这篇关于如何修复这些 SockJS ssl 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆