#How to make request.url_for() return HTTPS URI
1 messages · Page 1 of 1 (latest)
It seems that its obtained from scope["scheme"] but defaults to http
What would be the best way to set scope["scheme"] = 'https' during app startup
@warm sparrow any chance you've come by this before?
hmm, i'm looking in the test cases and we do have checks for that. Let me dig a little more to see how to set or override it
silly question, are you actually running with https?
(i didn't mean that rudely at all)
I just regularly deploy with Cloud Run
gunicorn app.main:app --workers 2 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8081
No worries
ok, so in cloud run, you aren't running encrypted
it's a requirement, i think
it's encrypted on the other side
from the proxy on
but, you do have an https endpoint
cloud run provisions an https endpoint to access
but i think you are right, from the app perspective its not running https
the cloud run proxy that points to my app is
but the litestar app itself isn't aware of that i guess
ok, cool. I think we are on the same page. I guess I'd have this issue too since i use cloud run
well, a quick fix for now would be to just .replace('http:','https:') to the end
but i think the proxy headers are probably there
are you able to see if there's anything in the headers that has the referring address/url?
maybe like an X-Forwarded-For or something similar
I can do the same, but i have IAP sitting in front
so i don't know if that changes things
in my case its just /v1/oauth2/github/login that returns a redirect to the URL construct from url_for()
no forwarded header
ok, let me look at look to see if i can find anything from our docs
and you have the run/invoke allowed for all in on the cloud run service?
yep
this probably does not need that much attention, but it would be nice to be able to override scheme for url_for() like Flask
I can create an issue for it
If it makes sense to you
And perhaps later it can be done
please do.
For now I'm totally fine replacing
does url_for always return a fully qualified URL?
afaik yes
this is not a feature I actually use currently (too many things to changing at a time!)
ok, it might be good to have a relative flag to pass in
and a scheme override
whenever you are ready.
🫡