【发布时间】:2020-05-09 18:47:01
【问题描述】:
我正在尝试提供我的 Angular SPA 并在同一个 Azure Web 应用程序上运行 Spring-boot 后端 API,以便它们共享同一个域。
我创建了一个虚拟目录api/ 用于运行我的后端并将根虚拟目录指向角度文件:
我在每个文件夹中使用了默认的web.config。在后台wwwroot/api:
<configuration>
<system.webServer>
<handlers>
<add name="MyhttpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "D:\home\site\wwwroot\api\my_packaged_api-1.0-SNAPSHOT.jar" ">
</httpPlatform>
</system.webServer>
</configuration>
在 Angular 应用文件夹中 wwwroot/dist :
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/assets/(.*)$" ignoreCase="true" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
问题
API 工作正常,但是当我尝试从我的 Angular 应用程序访问任何文件时,我从 tomcat 服务器得到 404。
查看启动的进程时,我看到在wwwroot/dist 中启动了第二个Java 进程。所有 404 最终都会出现在此进程日志中。
检查请求诊断我可以看到重写规则正常工作并找到我的文件。但似乎请求仍然传递给这个额外的 tomcat 进程并返回 404
我应该在 web.config 中更改什么以便它真正返回我的文件吗?
【问题讨论】:
标签: angular spring-boot iis azure-web-app-service azure-webapps