Plugin with catch-all wildcard route map

I’m working on a plugin which works as a kind of reverse proxy. It allows users to specify routes which upon requesting are forwarded to another URL. The goal is to allow arbitrary web applications to be served within a Discourse instance.

For this, I essentially need to handle all routes that were defined by the plugin users. Therefor, I thought, it’s necessary to catch all requests that aren’t handled by Discourse. In a nutshell, I have unknown paths (they might have multiple segments, query parameters, etc.) that I all want to use the same route for. The route then makes an AJAX call in order to forward the request and retrieve the web application’s content.

I do realize that this is a complex plugin and use case.


So far, I wasn’t able to make this work with any combination of dynamic path segments and wildcard path segments I tried.