Path based routing between multiple prodigy instances

Hi Team,

We are setting up a gateway application, that takes a path /nerannotations and relays response from prodigy instance hosted in a subdomain based URL like https://nerannotations.prodigy.example.com/.

The first request to http://localhost:8080/nerannotations is getting response from https://nerannotations.prodigy.example.com/ successfully. The successive requests for javascript files such as bundle.js receives 404 error

image

we want the request to go to http://localhost:8080/nerannotations/bundle.js so the gateway will get response from correct prodigy instance for all requests made with path /nerannotations.

how do we set a context path like /nerannotations to a prodigy instance?

Thanks,
Kamal.

Welcome to the forum @kamalakannan_kumar :wave:

Currently there's no way to define the context path via Prodigy configuration (and we are now considering adding a config or env variable for it). However, you can specify the root_path argument to FastAPI app object directly in the source code.
If you navigate to your prodigy installation directory > prodigy > app.py on line 200 there you can add the root path like so:

app = FastAPI(title="Prodigy", description=API_DOCSTRING, version=about.__version__, root_path="/nerannotations")

This root_path is like such context path that will be used to prefix all the routes defined in the app.
Please see FastAPI docs for more details on how it works and examples.

I quickly tested it with the local Prodigy instance (http://127.0.0.1:8000) and treafik proxy using the following treafik.toml:

 [entryPoints]
  [entryPoints.http]
    address = ":9999"

[providers]
  [providers.file]
    filename = "routes.toml"

where routes.toml is

[http]
  [http.middlewares]

    [http.middlewares.api-stripprefix.stripPrefix]
      prefixes = ["/nerannotations"]

  [http.routers]

    [http.routers.app-http]
      entryPoints = ["http"]
      service = "app"
      rule = "PathPrefix(`/nerannotations`)"
      middlewares = ["api-stripprefix"]

  [http.services]

    [http.services.app]
      [http.services.app.loadBalancer]
        [[http.services.app.loadBalancer.servers]]
          url = "http://127.0.0.1:8000"

This allows me to access both http://localhost:8080/nerannotations/and http://localhost:8080/nerannotations/bundle.js