尝试代理角度为4的rpoject时发生错误,URL配置为HTTPS

时间:2018-08-14 05:00:59

标签: angular angular4-router

我一直在尝试打入angular 4项目,该项目使用HTML页面的形式本地部署在我的计算机上的端口4200上:-

<!DOCTYPE html>
<html>
<body>
  <form action="https://test-pubg.sohum.com:4200" target="_blank" method="post">
    Access: <input type="text" id="accessToken" name="accessToken"><br> Refresh: <input type="text" id="refreshToken" name="refreshToken"><br>
    <button type="submit">Submit</button><br>
  </form>

</body>

</html>

但是我得到

  

尝试代理到以下地址时出错:test-pubg.sohum.com:4200 /

在浏览器上。

我已经在package.json中为 https 配置了路由配置,如下所示:

"start": "ng serve --disable-host-check --ssl 1 --proxy-config proxy.conf.json --host 0.0.0.0",

在proxy.conf.json中我的代理设置如下:-

{
    "/**": {
        "target": {
            "host": "test-pubg.sohum.com",
            "port": 8080,
            "protocol": "http:"
        },
        "secure": false,
        "changeOrigin": true,
        "logLevel": "debug"
    }
}

我已经在github和stackoverflow的其他类似线程上尝试了所有可能的解决方案。但是到目前为止,没有任何工作。

我是angel的新手,已经花了几天的时间。任何可能的解决方案将不胜感激。

1 个答案:

答案 0 :(得分:0)

因此,在花了很多时间之后,我发现它与架构问题有关。首先,尝试了解架构:- HTML(在其他服务器上)-> angular(HTTPS)-> spring boot

所以问题是Angular试图从HTTPS angular过渡到NON-HTTP Spring引导。因此,作为解决方案,我为春季启动和Voila配置了HTTPS!有效。

相关问题