#๐Ÿ”’ (Flask) Url_for Gives Localhost:5000 url instead of domain url for email verification.

4 messages ยท Page 1 of 1 (latest)

dawn flint
#

To give you an idea of my set up I am using an AWS EC2 instance behind an application load balancer. This EC2 instance is running Windows IIS which is configured to run a reverse proxy that redirects all traffic with pattern: "(.*)" to "http://localhost:5000/{R:1}" (Which I think may be part of the problem). From here Waitress takes over and I have a backend with python Flask.

I am trying to create an email verification system. The problem is the link that's sent to the user is with "locahost:5000" and not my domain name.

Whenever I try to manually change the Server name through:

app.config['SERVER_NAME'] = '{insert Website Name}'

I get:

C:\Python311\Lib\site-packages\flask\app.py:425: UserWarning: Current server name 'localhost:5000' doesn't match configured server name '{insert Website Name}'
return self.url_map.bind_to_environ(

The line that uses url_for looks like this:

verification_url = url_for('verify_email.verify_email_token', token=token, _external=True)

If you need any more info to diagnose the problem let me know.

midnight bluffBOT
#

@dawn flint

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

midnight bluffBOT
#

@dawn flint

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.