我正在开发两个独立的项目:一个是 Polymer
应用程序 Service worker
(使用 Polymer CLI 搭建支架)和第二个应用程序是 Spring Boot
与 Vaadin
及其集成库 Vaadin Spring
.这两个应用程序都在 localhost:8080
上运行.
在 SpringBoot 应用程序上,未经身份验证的用户被重定向到 /login
.身份验证成功后,用户应重定向回 /
,而是重定向到 url http://localhost:8080/service-worker.js
, 其中显示默认 Spring 404
页。当我手动将 url 改回 /
时,SpringBoot 应用程序再次运行。
我找不到问题的根源(如果是 Polymer 或 SpringBoot+Vaadin),每次清除缓存或手动更改 URL 都令人沮丧。
编辑:
我正在使用默认处理程序
SavedRequestAwareVaadinAuthenticationSuccessHandler
由 Vaadin Spring
提供.它应该重定向回之前的 URL 或回退 URL /
.@Bean(name = VaadinSharedSecurityConfiguration.VAADIN_AUTHENTICATION_SUCCESS_HANDLER_BEAN)
VaadinAuthenticationSuccessHandler vaadinAuthenticationSuccessHandler(@SuppressWarnings("SpringJavaAutowiringInspection") HttpService httpService, VaadinRedirectStrategy vaadinRedirectStrategy) {
return new SavedRequestAwareVaadinAuthenticationSuccessHandler(httpService, vaadinRedirectStrategy, "/");
}
最佳答案
我解决了。
转到 localhost:8080/login -> Inspect (ctrl+shift+I) -> Application tab -> 选择 Service Worker 并取消注册 sw.js
祝你好运!
关于spring - 浏览器被重定向到 service-worker.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37919012/