Skip to content
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

Add setting to fix runserver_plus debugger on custom host names #1878

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions django_extensions/management/commands/runserver_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,11 @@ def make_environ(self):
if self.nopin:
os.environ['WERKZEUG_DEBUG_PIN'] = 'off'
handler = DebuggedApplication(handler, True)
# Set trusted_hosts (for Werkzeug 3.0.3+)
try:
handler.trusted_hosts = settings.RUNSERVERPLUS_TRUSTED_HOSTS
except AttributeError:
pass

runserver_plus_started.send(sender=self)
run_simple(
Expand Down
19 changes: 15 additions & 4 deletions docs/runserver_plus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,18 @@ An ajax based console appears in the pane and you can start debugging.
Notice in the screenshot above I did a `print environ` to see what was in the
environment parameter coming into the function.

*WARNING*: This should *never* be used in any kind of production environment.
Not even for a quick problem check. I cannot emphasize this enough. The
interactive debugger allows you to evaluate python code right against the
server. You've been warned.
.. warning::

This should *never* be used in any kind of production environment.
Not even for a quick problem check. I cannot emphasize this enough. The
interactive debugger allows you to evaluate python code right against the
server. You've been warned.

.. note::

If you're using Werkzeug 3.0.3 or later, by default, the debugger will only
be enabled if the hostname is one of ``[localhost, .localhost, 127.0.0.1]``.
You may allow more host names by setting the ``RUNSERVERPLUS_TRUSTED_HOSTS``.

.. _`Werkzeug WSGI utilities`: https://werkzeug.palletsprojects.com/

Expand Down Expand Up @@ -209,6 +217,9 @@ Other configuration options and their defaults include:
# Do not watch files matching any of these patterns
RUNSERVER_PLUS_EXCLUDE_PATTERNS = []

# List of domains to allow requests to the debugger from
RUNSERVERPLUS_TRUSTED_HOSTS = [".localhost", "127.0.0.1"]


IO Calls and CPU Usage
^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading