我有一个由前端代码组成的 Web 应用程序,它调用由两个后端模块实现的相同 api。这个 api 返回一个 JSON 对象中的 url。后端模块都是用 spring mvc 编写的,但版本不同。url-building 是一样的,它是这样的:
@GetMapping(path = "/app1/menu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public JsonObject getMenu(HttpServletRequest req) throws IOException {
JsonObject menu = new JsonObject();
menu.addProperty("href", ServletUriComponentsBuilder.fromRequest(req)
.replacePath(req.getContextPath())
.path("/index.html")
.toUriString());
return menu;
}
Run Code Online (Sandbox Code Playgroud)
如您所见,此代码只是向传入的请求添加一个常量并返回它。第一个应用程序使用 spring mvc 4(准确地说是 4.3.5.RELEASE)。第二个模块使用 5.1.4.RELEASE 版本。当所有这些应用程序都部署在负载均衡服务器(2 个带有负载均衡器的 tomcat 实例)和 https 上时,问题就出现了。假设请求 url 对于 app1 是这样的:
https://example.com/context/app1/menu
Run Code Online (Sandbox Code Playgroud)
app1 正确返回
https://example.com/context/index.html
Run Code Online (Sandbox Code Playgroud)
对于 app2,前端发出的请求是 https://example.com/context/app2/menu
答案是 http://example.com/context/another_index.html
所以它失去了 https 方案
似乎 ServletUriComponentsBuilder.fromRequest 改变了行为?我已经(我承认很快)查看了 git repo 中的提交,但没有找到任何东西......
我正在尝试构建一个包含 PHP 应用程序的 docker 映像。
\n该应用程序通过composer.json安装一些依赖项,并且在安装composer后,需要完成一些自定义(例如,必须将某些文件从供应商文件夹复制到其他位置等)。
\n因此,我将这些步骤编写为 bash 命令,并将其放入composer.json post-install-cmd 部分中。
\n这是我的composer.json(我省略了细节,但结构是相同的):
\n{\n "name": "MyApp",\n "description": "My Service",\n "type": "project",\n "repositories": {\n "a-fancy-library-i-depend-on": {\n "type": "package",\n "package": {\n "name": "a-fancy-library-i-depend-on",\n "version": "1.0",\n "source": {\n "url": "https://github.com/a-fancy-library-i-depend-on",\n "type": "git",\n "reference": "master"\n }\n }\n },\n },\n "require": {\n "symfony/filesystem": "5.2.6",\n "symfony/yaml": "^4.2"\n },\n "require-dev": {\n "a-fancy-library-i-depend-on": "*"\n },\n "scripts": {\n "post-install-cmd": [\n "rm -rf ./src/setup",\n "cp -r vendor/a-fancy-library-i-depend-on/setup/ ./src/setup",\n "mkdir vendor/a-fancy-library-i-depend-on/log"\n ]\n },\n "autoload": {\n "classmap": [\n "src/"\n …Run Code Online (Sandbox Code Playgroud)