浏览器被重定向到 service-worker.js

Lou*_*her 5 spring vaadin polymer spring-boot service-worker

我正在开发两个独立的项目:一个是Polymerapp with Service worker(用 Polymer CLI搭建支架),第二个 app 是Spring BootwithVaadin及其 itegration library Vaadin Spring。这两个应用程序都在localhost:8080.

在 SpringBoot 应用程序上,未经身份验证的用户被重定向到/login. 身份验证成功后,用户应该重定向回/,而是重定向到 url http://localhost:8080/service-worker.js,其中显示了默认的 spring404页面。当我手动将 url 改回 时/,SpringBoot 应用程序又开始工作了。

  • 这种行为发生在我使用 Polymer 应用程序并切换到 SpringBoot 之后
  • 在 Chrome 和 Firefox 上测试
  • 清除浏览器缓存有帮助
  • Vaadin 也在使用 hashbang

我找不到问题的根源(如果是 Polymer 或 SpringBoot+Vaadin),每次清除缓存或手动更改 URL 都令人沮丧。

编辑:

我正在使用SavedRequestAwareVaadinAuthenticationSuccessHandlerVaadin Spring. 它应该重定向回以前的 URL 或回退 URL /

@Bean(name = VaadinSharedSecurityConfiguration.VAADIN_AUTHENTICATION_SUCCESS_HANDLER_BEAN)
VaadinAuthenticationSuccessHandler vaadinAuthenticationSuccessHandler(@SuppressWarnings("SpringJavaAutowiringInspection") HttpService httpService, VaadinRedirectStrategy vaadinRedirectStrategy) {
    return new SavedRequestAwareVaadinAuthenticationSuccessHandler(httpService, vaadinRedirectStrategy, "/");
}
Run Code Online (Sandbox Code Playgroud)

Sla*_*vus 4

我有同样的问题。这是浏览器的事情,您无法从应用程序或服务器端进行记录。

我通过手动删除 chrome 中本地主机地址的服务工作者解决了 ti 问题。

您可以通过在 chrome -> 选项卡资源 -> Service Workers 中打开开发人员工具来完成此操作
,在特定网址(例如 http://localhost:8080/login)上找到您的 Service Worker 并将其删除。

另一种选择是使用不同的本地主机(localhost、127.0.0.1、127.0.0.2)IP 地址来开发聚合物应用程序和 Vaadin 应用程序。