Vaadin forwardTo doesnt redirect appropriately

I’m attempting to have my custom RouteNotFoundError redirect back to the “home” view.

When the redirect happens I can see the URL briefly change to “home” but then it goes back to whatever garbage i put in…Can someone please tell me whats wrong here?

@ParentLayout(MainLayout.class)
@PageTitle(IdeaConst.TITLE_NOT_FOUND)
@JsModule("./styles/shared-styles.js")
public class CustomRouteNotFoundError extends RouteNotFoundError {

	public CustomRouteNotFoundError() {
		System.out.println("Route not found.");
	}

	@Override
	public int setErrorParameter(BeforeEnterEvent event, ErrorParameter<NotFoundException> parameter) {
            event.forwardTo("home");
            return HttpServletResponse.SC_NOT_FOUND;
	}
}
@PageTitle("Welcome")
@Route(value = "home", layout = MainLayout.class)
@RouteAlias(value = IdeaConst.PAGE_ROOT, layout = MainLayout.class)
public class Home extends ViewFrame {

    public Home() {
        setId("home");
        setViewContent(createContent());
    }

    private Component createContent() {
		FlexBoxLayout content = new FlexBoxLayout();
        content.setAlignItems(FlexComponent.Alignment.CENTER);
        content.setFlexDirection(FlexDirection.COLUMN);
        return content;
	}
}

I tried event.rerouteTo("home"); and that reroutes appropriately but the URL doesnt change.

However event.forwardTo("home"); doesnt do either with used in the way listed above.

I think your finding is somewhat linked to this ticket on GitHub issue tracker https://github.com/vaadin/flow/issues/5173

It is definitely somewhat linked, as the behavior is the same.

However the work around indicated in the bug doesn’t work in my case.

The best I could do is add a check prior to navigation that checks if the destination route is valid, and if not, reroute back to home?