首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Juniper SSL VPN中的角度web应用路由

Juniper SSL VPN中的角度web应用路由
EN

Stack Overflow用户
提问于 2015-06-05 05:28:25
回答 3查看 3.2K关注 0票数 4

目前,我正在使用AngularJS开发一个简单的web应用程序。在开发过程中,当IIS在本地服务应用程序时,我测试了它。但是,当我将它部署到公司的web服务器上并在Juniper中运行时,问题就开始了。

首先,我必须应用以下“修复”:在Juniper #8905中运行时,AngularJS路由失败

但上述修正只解决了部分麻烦。仍然存在的问题是,AngularJS在尝试从视图控制器加载默认视图('/')视图($location.path(‘/其他视图’)之外的其他视图时,会得到以下错误消息:

代码语言:javascript
运行
复制
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D
    at REGEX_STRING_REGEXP (,DanaInfo=server1.mydomain.nl,CT=js+angular.js:63)
    at Scope.$get.Scope.$digest (,DanaInfo=server1.mydomain.nl,CT=js+angular.js:14340)
    at Scope.$get.Scope.$apply (,DanaInfo=server1.mydomain.nl,CT=js+angular.js:14565)
    at done (,DanaInfo=server1.mydomain.nl,CT=js+angular.js:9685)
    at completeRequest (,DanaInfo=server1.mydomain.nl,CT=js+angular.js:9875)
    at XMLHttpRequest.requestLoaded (,DanaInfo=server1.mydomain.nl,CT=js+angular.js:9816)(anonymous function) @ ,DanaInfo=server1.mydomain.nl,CT=js+angular.js:11649$get @ ,DanaInfo=server1.mydomain.nl,CT=js+angular.js:8583$get.Scope.$apply @ ,DanaInfo=server1.mydomain.nl,CT=js+angular.js:14567done @ ,DanaInfo=server1.mydomain.nl,CT=js+angular.js:9685completeRequest @ ,DanaInfo=server1.mydomain.nl,CT=js+angular.js:9875requestLoaded @ ,DanaInfo=server1.mydomain.nl,CT=js+angular.js:9816

我已经用默认的AngularJS路由和角度ui.router机制测试了它,两者都给出了相同的结果。

任何解决这个问题的帮助都是非常感谢的!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-07-08 04:50:09

通过配置Juniper作为反向代理解决了问题。

票数 2
EN

Stack Overflow用户

发布于 2015-09-30 22:43:08

我们通过在核心parseAppUrl代码库中修补Angular.js函数来解决这个问题,如下所示:

代码语言:javascript
运行
复制
function parseAppUrl(relativeUrl, locationObj, appBase) {
  var prefixed = (relativeUrl.charAt(0) !== '/');
  if (prefixed) {
    relativeUrl = '/' + relativeUrl;
  }
  var match = urlResolve(relativeUrl, appBase);
  locationObj.$$path = decodeURIComponent(prefixed && match.pathname.charAt(0) === '/' ?
      match.pathname.substring(1) : match.pathname);
  locationObj.$$search = parseKeyValue(match.search);
  locationObj.$$hash = decodeURIComponent(match.hash);

  //Detect Juniper re-write functions and handle the $$path issue
  if(locationObj.$$path === "[object Object]" && typeof(DanaOrigUrl) === 'function') {
    var __strH = 'href';
    var __tmpHack = match[__strH];
    var __nn = ("" + __tmpHack).match(/^(https?:\/\/[^\/]+)?([^?|#]*)/);
    locationObj.$$path = __nn[2];
  }
  // make sure path starts with '/';
  if (locationObj.$$path && locationObj.$$path.charAt(0) != '/') {
    locationObj.$$path = '/' + locationObj.$$path;
  }
}

参考资料:https://github.com/angular/angular.js/issues/8905

票数 0
EN

Stack Overflow用户

发布于 2017-04-19 14:29:15

在我的例子中,我在重写URL时遇到了问题。网关使用标准的href属性做得很好,但对于角度AJAX调用则不是这样。所以我写了一个拦截器来完成这个任务:

角2 (JavaScript)

代码语言:javascript
运行
复制
app.config( function( $httpProvider ) {
  $httpProvider.interceptors.push( function( $q, $rootScope ) {
    return {
      'request': function( config ) {
        // Convert request URL for Juniper Secure Web Access
        if ( typeof DanaUrl === "function" && !config.url.includes( '.html' ) ) {
          config.url = DanaUrl( config.url );
        }
        return config;
      }
    };
  } );
} );

角5+ (TypeScript)

代码语言:javascript
运行
复制
import { Injectable } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor, HttpResponse, HttpErrorResponse, HttpHeaders } from '@angular/common/http';

declare function DanaUrl(url: string): string;

@Injectable()
export class CustomHttpInterceptor implements HttpInterceptor {
constructor(
) { }

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

    // Rewrite Juniper SWA URLs
    if ( typeof DanaUrl === "function" && !request.url.includes( '.html' ) ) {
        request = request.clone({
            url: DanaUrl( request.url )
        });
    }

    return next.handle(request).do((event: HttpEvent<any>) => {
        if (event instanceof HttpResponse) {
            // do stuff with response if needed
        }
    }, (err: HttpErrorResponse) => {

    }).finally(() => {

    });
}

}

如果Juniper的DanaURL函数可用,并且URL不包含".html“,URL将被重写。这是因为Angular使用URL将视图包含到模板中,甚至包括视图(例如,在脚本标记中)。(我不喜欢这部分,但现在它正在工作.)

我希望这对某人有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30658940

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档