I’ve set up an uvicorn API server with FastAPI in docker behind Traefik v2.2 proxy. Traefik is configured to use Let’s Encrypt resolver to automatically deal with the SSL stuff for the hostname of this service so all the clients are talking with this API endpoint in https url e.g. https://foo.bar and the API service itself (the uvicorn server) is running in non-ssl mode. Everything works fine in normal cases.
However, in certain cases, the API endpoint will send out some redirect responses. Unfortunately, those redirect response is targeting to http://foo.bar which is a different hostname because of the wrong scheme as the request from traefik router (the proxy) to my service is tweaked to http request though the original request from client to traefik is https.
The client receiving such a redirect response will not carry the Authorization Header by default because the hostname has changed (from https to http). As a result, many services can’t work properly.
Per talk with the Traefik community, the suggestion is to configure the root_url or something similar of my service (fastapi+uvicorn here). However I was not able find relevant configurations neither in fastapi nor in uvicorn. Hope I could get some help here. Thank you all in advance!