hilla
hilla copied to clipboard
Fusion endpoints do not work if accessed via mapped servlet URL
Steps to reproduce:
- Navigate to https://cookbook.vaadin.com/vaadinServlet/
- Observe error in console:
18:10:30.552 (index):1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
Promise.catch (async)
render @ vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2399
__onNavigationEvent @ vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2399
setRoutes @ vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2399
(anonymous) @ vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2847
i @ vaadin-bundle-5a8c8610a0f26788a61d.cache.js:1
(anonymous) @ vaadin-bundle-5a8c8610a0f26788a61d.cache.js:1
(anonymous) @ vaadin-bundle-5a8c8610a0f26788a61d.cache.js:1
- Observe that request to
https://cookbook.vaadin.com/vaadinServlet/connect/RecipeEndpoint/listreturns HTML content.
Related to https://github.com/vaadin/flow/issues/7521, the difference is that vaadin/flow#7521 is about the vaadin.urlMapping.
This ticket is about using a custom servlet-mapping, e.g.
@WebServlet("/path/*")
public class WorkaroundServlet extends VaadinServlet {
}
Note, for a Spring application, also need a @ServletComponentScan onto the Application.java to make the custom servlet mapping work.
Remove the Spring dependency for endpoint would fix this issue automatically.