Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rest 在具有上下文路径的Spring Boot应用程序中使用API网关时,HATEOAS路径无效_Rest_Spring Cloud_Netflix Zuul_Spring Cloud Netflix_Spring Hateoas - Fatal编程技术网

Rest 在具有上下文路径的Spring Boot应用程序中使用API网关时,HATEOAS路径无效

Rest 在具有上下文路径的Spring Boot应用程序中使用API网关时,HATEOAS路径无效,rest,spring-cloud,netflix-zuul,spring-cloud-netflix,spring-hateoas,Rest,Spring Cloud,Netflix Zuul,Spring Cloud Netflix,Spring Hateoas,我在zuul网关后面有一个SpringBoot2.0.2Web应用程序。我的应用程序使用spring hateoas链接。我的应用程序还设置了上下文路径,比如xxx 当通过zuul网关进行查询时,hateoas链接无效。原因如下: 我们打个电话吧。我会要求我的heteoas链接成为。 但是,这些链接变为: 我已搜索并在堆栈溢出中找到此链接() 事实上,默认情况下,addproxy头true发送X-FORWARDED-PREFIX(allonghost等),我想这是community解决这个问题的

我在zuul网关后面有一个SpringBoot2.0.2Web应用程序。我的应用程序使用spring hateoas链接。我的应用程序还设置了上下文路径,比如xxx

当通过zuul网关进行查询时,hateoas链接无效。原因如下: 我们打个电话吧。我会要求我的heteoas链接成为。 但是,这些链接变为:

我已搜索并在堆栈溢出中找到此链接() 事实上,默认情况下,addproxy头true发送X-FORWARDED-PREFIX(allonghost等),我想这是community解决这个问题的意图。但是当我调试我的应用程序时,我找到了这个方法org.springframework.web.servlet.support.ServletUriComponentsBuilder#fromContextPath,java文档部分如下: 从4.3.15开始,此方法将contextPath替换为值“X-Forwarded-Prefix”,而不是前缀,从而与{@code ForwardedHeaderFiller}对齐

这意味着,当存在X-FORWARDED-PREFIX时,应用程序上下文将从zuul的前缀(即serviceName)中替换。我猜uul开发人员无法了解应用程序上下文,而另一方面,org.springframework.web.servlet.support.ServletUriComponentsBuilder#fromContextPath与相应的规范兼容


问题:我如何进行?当我使用zuul时,我当然希望我的hateoas链接是正确的,我的问题是这里没有解决方案。 正确的方法是避免使用zuul并转移到SpringCloudGateway