首页 > 解决方案 > 如何在 AWS API Gateway 上为 Angular 推送状态路由添加重写规则

问题描述

Angular Server Configuration 部分,您可以阅读有关如何为不同的服务器设置(例如 IIS(我已经成功完成))配置回退/url 重写到 index.html 的信息。

我正在互联网上搜索(到目前为止没有任何成功)寻找类似的解决方案,但适用于 AWS API Gateway。有没有人知道如何在该技术堆栈中进行 url 重写?即我想让 url 重写类似于这个(对于 IIS)但对于 AWS API Gateway:

<?xml version="1.0" encoding="utf-8"?>
<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" />
        </conditions>
        <action type="Rewrite" url="./index.html" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

</configuration>

标签: angularamazon-web-servicesaws-api-gatewayangular-routing

解决方案


推荐阅读