Default route to serve index.html if nothing else matches

What we need to do is serve index.html whenever the route is one that isn’t recognized by any of the other endpoints. Is there a way to do this?

(Specifically, we are using an Angular front end, and we need to redirect the user back into the front end if they enter a route that the front end doesn’t capture (see Angular). We’re using zio-http as the http server).

Sorry, somehow this got flagged as spam - do you still have this problem?

Hi Adam. Yes, we haven’t been able to figure out how to do this.

Would having an endpoint such as this:

endpoint.get.out(stringBody).serverLogic(_ => Right("<html>Hello, world</html>"))

work? You’d need to add the endpoint to the end of your endpoint list. Alternatively, you can define a path prefix which has to match:

endpoint.get.in("a"/"b").in(paths).out(stringBody).serverLogic(_ => Right("<html>Hello, world</html>"))