Vaadin 25 and vaadin.urlMapping

I’m playing around with Vaadin 25. (25.0.0-beta9)

In my test project i am using an application.properties file with
vaadin.urlMapping = /ui/*
because i want to separate /api and /ui

This breaks the themes, because getting theme files now goes to /ui/aura/aura.css
and this results in 404.

Does it work if you use @StyleSheet("ui/aura/aura.css") instead of the provided constant for the path?

When using vaadin.urlMapping in combination with the @StyleSheet annotation, you need to specify the context:// “protocol”, since Aura and Lumo CSS are served directly by the servlet container (@StyleSheet("context://aura/aura.css").

The same goes for all stylesheets loaded from static resources folders (e.g. META-INF/resources), e.g. for META-INF/resources/styles.css use @StyleSheet("context://styles.css")

1 Like

Thanks for this. It is working now.

BTW:
@StyleSheet( “context://” + Lumo.STYLESHEET )
does work, too.

The documentation may need to be supplemented accordingly.

Thanks for confirming.

We’re actually considering to make it use context:// by default so that not special documentation would even be needed.

Thanks for this, but i used the Solution from Marco.
I did not try yours, but i think, Marcos way is the “official” anyway.

This is basically described in How to load resources dynamically in Vaadin, but mentioning the Java method, not annotation.

Created a new feature for this Add "context://" automatically for custom URL mapping · Issue #22888 · vaadin/flow · GitHub.