-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using request.url_for throws KeyError: 'SERVER_NAME' in 19.9.0 #1707
Labels
Comments
if "//" in self.app.config.SERVER_NAME:
return self.app.url_for(view_name, _external=True, **kwargs) I believe this got introduced as part of 1e4b1c4 This can easily be mitigated with the help of a |
harshanarayana
added a commit
to harshanarayana/sanic
that referenced
this issue
Oct 23, 2019
@roemba As a workaround until the fix gets released, you may define |
Thanks for the quick response! Will try out the workaround today. Edit: Works great! |
harshanarayana
added a commit
to harshanarayana/sanic
that referenced
this issue
Oct 26, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Running Sanic behind a proxy and trying to generate an url using
request.url_for
throws a KeyError. This used to work but now Sanic suddenly requires a SERVER_NAME in order to do this. I get the following trace:Code snippet
request.url_for("static", name='static', filename="badge.png")
Expected behavior
request.url_for
should generate a full url with the given path, e.g.https://hostname:port/static/badge.png
. As I am running my server behind a proxy, I do not want to hardcode the hostname in the SERVER_NAME. This used to work with Sanic version 19.6.3.Environment (please complete the following information):
Additional context
The calling code to
request.url_for
has not changed since the Sanic version update.The documentation also does not speak a word about why the SERVER_NAME variable needs to be configured...
The text was updated successfully, but these errors were encountered: