【问题标题】:UI-Router - templateUrl: "The content must be served over HTTPS"UI-Router - templateUrl:“内容必须通过 HTTPS 提供”
【发布时间】:2015-08-19 07:16:59
【问题描述】:

我使用 HTTPS。我需要发送templateUrl 请求,不是静态文件,而是路由器:

 /:lang/content/library/book/:bookId

这是我的state

.state('book', {
    url: '/:lang/library/book/:bookId',
    controller: 'BookCtrl',
    templateUrl: function(stateParams) {
      return stateParams.lang + '/content/library/book/' + stateParams.bookId;
      // or: 'https://dev.mysite.com/' +  stateParams.lang + '/content/library/book/' + stateParams.bookId;
    }
  });

当我运行我的应用程序时,我收到以下错误:

Mixed Content: The page at 'https://dev.mysite.com/en/library/book/4985459864' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://dev.mysite.com/en/content/library/book/4985459864'. This request has been blocked; the content must be served over HTTPS.

如何使用ui-router 发送HTTPS 请求templateUrl

【问题讨论】:

  • 首先,如果有人或某物试图连接到 http,您是否更喜欢 https 重定向?我不知道您将什么用作网络服务器,但请尝试在您的网络服务器的配置中设置 https 重定向。 2. https:// 绝对网址对您有用吗? 3. 尝试在 stateParams.lang 前添加一个“/”
  • HTTPS 绝对 URL 对我不起作用

标签: javascript angularjs angular-ui-router


【解决方案1】:

如何使用 ui-router 为 templateUrl 发送 HTTPS 请求?

这是 ui-router 的正常行为。 ui-router 使用$location 解析协议

您是否尝试过清理缓存?如果您或用户首先使用基于 HTTP 的非安全 URL,然后切换到 HTTPS,他们将不得不下载已通过 HTTP 访问的资源的新副本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-18
    • 1970-01-01
    • 2015-03-23
    • 2016-08-28
    • 1970-01-01
    • 2023-01-30
    相关资源
    最近更新 更多