swagger icon indicating copy to clipboard operation
swagger copied to clipboard

Don't store the path prefix as global app state but derive it on a per-request basis

Open mgoltzsche opened this issue 1 year ago • 0 comments

Currently the path prefix is derived from the X-Forwarded-Prefix HTTP header of the first request only and then applied to every subsequent request (see here). The header may be specified by a reverse-proxy that exposes the web app under a different path.

However, applying the prefix of the first request to all requests is a problem because:

  • when reconfiguring the reverse-proxy with a different prefix the change is not applied, unless the web app is restarted.
  • it does not allow using the web app with multiple path prefixes simultaneously (e.g. when letting a reverse-proxy expose it with a path prefix while still letting another client access the web app directly, bypassing the reverse-proxy).

Thus, I suggest to derive the path prefix on a per-request basis and to not store the result as global application state.

Relates to:

  • https://github.com/mudler/LocalAI/pull/4497
  • #104

mgoltzsche avatar Dec 27 '24 00:12 mgoltzsche