seletz
seletz

Reputation: 33

Vaadin 14 how to move the vaadin servlet to a different URL?

I have a pretty basic vaadin application running. The application is spring-boot backed and I defined some rest API.

I've added OpenAPI documentation using org.springdoc:springdoc-openapi-ui:1.4.4, which worked perfectly before adding vaadin.

After adding the vaadin dependencies as shown in the vaadin spring-boot tutorial, and creating a view (which works), the swagger UI is no longer reachable.

It seems to me that vaadin completely takes over all web requests. Digging deeper, I've found that vaadin registers a new servlet and catches all requests.

I don't find any docs on how to configure this -- I'd expect that one could configure vaadin such that it serves UI from a different path, say /ui or similar.

I've tried to set

vaadin:
   url-mapping: "/ui/*"

in my application.yaml -- but this results in blank pages (no errors) for my vaadin views, and the vaadin servlet does still take over /.

I use spring.boot 2.3.2.RELEASE, vaadin 14.3.1.

Upvotes: 3

Views: 1237

Answers (1)

cfrick
cfrick

Reputation: 37008

The value to override is (note the camelCase instead of the kebab-case):

vaadin:
  urlMapping: /ui/*

Using the kebab-case did (does) not work. As expected, this is a bug. See https://github.com/vaadin/spring/issues/637

From the docs at the point of time:

You can set properties for Spring Boot in your application.properties file.

Example: Setting Spring URL mapping in application.properties.

vaadin.urlMapping=/my_mapping/*

By default, URL mapping is /*.

An additional servlet, such as /my_mapping/*, is required to handle the frontend resources for non-root servlets. The servlet can be defined in your application class. See this Application class for a example.


Source: https://vaadin.com/docs/v14/flow/spring/tutorial-spring-configuration.html#using-spring-boot-properties

Upvotes: 3

Related Questions