hilla icon indicating copy to clipboard operation
hilla copied to clipboard

Fusion endpoints do not work if accessed via mapped servlet URL

Open fluorumlabs opened this issue 5 years ago • 1 comments

Steps to reproduce:

  1. Navigate to https://cookbook.vaadin.com/vaadinServlet/
  2. 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
  1. Observe that request to https://cookbook.vaadin.com/vaadinServlet/connect/RecipeEndpoint/list returns HTML content.

fluorumlabs avatar Nov 19 '20 16:11 fluorumlabs

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.

haijian-vaadin avatar Nov 24 '20 11:11 haijian-vaadin