【问题标题】:Error 403 when refreshing an angular app in Wildfly在 Wildfly 中刷新 Angular 应用程序时出现错误 403
【发布时间】:2018-06-29 09:12:25
【问题描述】:

我已经使用哈希定位策略实现了一个 Angular 6 应用程序,并希望将其部署为 Wildfly 中的 WAR。应用程序运行良好,但是重新加载页面(例如http://localhost:9390/MyApp/app/#/login)会导致 403 禁止错误。这是设置:

WAR 文件:

/app/* -> angular app generated by ng-cli
/error403.html -> simple error page
/WEB-INF
/WEB-INF/web.xml
/WEB-INF/classes/... REST services

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>MyApp</display-name>

    <welcome-file-list>
        <welcome-file>app/index.html</welcome-file>
    </welcome-file-list>


    <error-page>
        <error-code>403</error-code>
        <location>/error403.html</location>
    </error-page>
</web-app>

感谢您的帮助。

【问题讨论】:

    标签: angular wildfly war http-status-code-403


    【解决方案1】:

    可能涉及的对象: 403 错误是由于基于散列的定位策略而发生的。 URI 中以 # 开头的所有内容在发送到客户端之前都会被删除。在我的示例中,URL 以 /app/ 结尾,它被 undertow 识别为目录。由于默认情况下不允许目录列表,因此返回 403。解决方案是实现一个WebFilter,它检测到这个请求并重定向到角度页面/app/index.html。

    【讨论】:

    • 你能发布你的网络过滤器实现吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-07
    • 2018-11-07
    • 1970-01-01
    • 1970-01-01
    • 2020-03-27
    • 1970-01-01
    相关资源
    最近更新 更多