OpenApiFeature Ignores WebHostUrl

Hi, OpenApiFeature Ignores WebHostUrl, and when you open the links to the Swagger UI does not show anything.
How to fix?
Thanks.

SetConfig(new HostConfig {
         DefaultRedirectPath = "{AppSettings.Get("BASE_URL", "")}/metadata",
         DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), false),
         WebHostUrl =  AppSettings.Get("BASE_URL", "")
 });

 Plugins.Add(new OpenApiFeature());

Can you provide more details, please provide the HTTP Request/Response of the /metadata page and the HTTP Request/Response of the /swagger-ui/.

What’s your BaseUrl that ServiceStack is hosted on and what’s the WebHostUrl you’re changing it to?

Also please use null when you don’t want to set a property (instead of empty string), e.g:

WebHostUrl =  AppSettings.GetString("BASE_URL")

I run the server in k8s, I have such settings, everything works, except OpenApi

Ingress vonfig

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
   name: ingress
   annotations:
     nginx.ingress.kubernetes.io/rewrite-target: /
     nginx.ingress.kubernetes.io/add-base-url : "true"
 
spec:
  tls:
  - hosts:
    - my.host.com
    secretName: ingress-tls-secret
  
  rules:
  - host: my.host.com
    http:
     paths:
      - path: /fkm
        backend:
         serviceName: fkm
         servicePort: 80

Deployment environment values

  env:
        - name: BASE_URL
          value: "/fkm"  
        - name: REDIS_URL
          value: "redis-server"

This doesn’t help, I need to be able to first identify the issue then be able to repro it and I don’t know what’s not working or why, what do you mean by Open API not working, i.e. do you mean /swagger-ui or the /openapi endpoint or both?

Please provide the raw HTTP Request/Response of the /metadata page as well as /swagger-ui/ and /openapi.

Look, please, these are links to the service, I hope it will be clear what I mean.

link to services: https://fkm.e-teleport.ru/fkm/ - works
https://fkm.e-teleport.ru/fkm/openapi - works
https://fkm.e-teleport.ru/fkm/swagger-ui/ - not work

Who put this <base href/> in https://fkm.e-teleport.ru/fkm/swagger-ui/ ?

<!DOCTYPE html>
<html>
<head><base href="https://fkm.e-teleport.ru/fkm/">

This is not in the default /swagger-ui/index.html and is what’s breaking the page.

This is the question, the service is located at https://fkm.e-teleport.ru/fkm/
so that everything works, I made the following setting:

SetConfig(new HostConfig {
         DefaultRedirectPath = "fkm/metadata",
         DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), false),
         WebHostUrl =  "fkm"
 });

as I wrote earlier, the service starts in k8s, and I configure the ingress as indicated by

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
   name: ingress
   annotations:
     nginx.ingress.kubernetes.io/rewrite-target: /
     nginx.ingress.kubernetes.io/add-base-url : "true"
 
spec:
  tls:
  - hosts:
    -  fkm.e-teleport.ru
    secretName: ingress-tls-secret
  
  rules:
  - host: fkm.e-teleport.ru
    http:
     paths:
      - path: /fkm
        backend:
         serviceName: fkm
         servicePort: 80

The <base href/> that’s injected in your page is not in ServiceStack, so something else you’re using is injecting it, I don’t know what you’re using that’s doing it, this is something you need to find out yourself, i.e. by disabling features and checking if it’s there when running locally or just under k8.

You can also override the default Swagger Resources by copying the files and adding it to your host project which will give you control over the HTML returned, but if you’re using a reverse proxy that’s injecting the <base href> you’re going to have the same problem, you can try adding your own further down the page to override what’s injected.

<base href="https://fkm.e-teleport.ru/fkm/swagger-ui/">

Look, in order for redirection to work when opening links, I indicated in the settings of “WebHostUrl =” fkm ", and when I click on the link, it does not open fkm.e-teleport.ru/json/metadata?op=DocumentGetListFull but fkm.e-teleport.ru/fkm/json/metadata?op=DocumentGetListFull.

probably it would be logical to use WebHostUrl = "fkm" in <base href = "WebHostUrl / swagger-ui /">

I just did not find how to do it :frowning: