Hi there, I need to build an URL from into a blueprint pointing to another internal endpoint, but when using url_for it doesn’t contain the host on which the server is running, I have to do it manually e.g.
app = Sanic(__name__)
app.config["SERVER_NAME"] = "127.0.0.1:8080
Which feels wrong as web services could be dynamically deployed using any random URL.
If I don’t setup manually the hostname I’ll get something like this
https:///api/v1/upservice/callback
I could build manually it doing something like:
def url_for(request, endpoint: str) -> str:
return f"{request.scheme}://{request.host}/{endpoint}""
But I’m wondering if I’m missing something else or is this a Sanic issue as url_for should be doing that?
Thanks!
Edit: My current workaround:
request.app.url_for("myprefix.mycallback", _external=True, _server=request.headers.get("host"))
Though I’d insist that this should be done by url_for internally