REST API returns 200 OK for invalid endpoint instead of 404 Not Found

Hi everyone,

I’m using the REST API addon provided by Jmix and followed the official documentation to set it up.
I created a role called test-role, granted the necessary permissions, and verified that my client (my-client) can successfully send a GET request to the endpoint:

http://localhost:8080/rest/entities/User

Everything works fine so far.

Now to the issue:
When I send a request to a non-existent endpoint, for example:

http://localhost:8080/rest/myendpoint/

…I receive an HTML response with status 200 OK instead of the expected 404 Not Found.

This behavior is not limited to Jmix REST endpoints. We’re also exposing custom Spring endpoints in the same application, and for those as well, invalid paths return an HTML page with status 200 instead of a proper 404 error.

Is this the intended behavior? Could it be related to some general error handling configuration in the application?
Are there any plans to improve this?

I’ve uploaded a demo project that reproduces the issue.
jmixrestdemo.zip (1.0 MB)

Thanks in advance!

Hi Tim,

You receive HTTP 200 because Vaadin handles these requests and returns some default page.

To receive HTTP 404 for wrong URLs in the whole /rest and, for example /api paths, add the following application property:

vaadin.exclude-urls=/rest/**,/api/**

Regards,
Konstantin

1 Like