Opened 5 years ago

Last modified 5 years ago

#31010 closed New feature

Add subdomains of localhost to ALLOWED_HOSTS in DEBUG mode — at Version 3

Reported by: thenewguy Owned by: nobody
Component: HTTP handling Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by thenewguy)

It would minimize configuration for new projects if ALLOWED_HOSTS += .localhost when DEBUG=True

Chrome resolves *.localhost to localhost without modifying any host files or DNS

Referencing the project this way makes it easy to test subdomains -> static.localhost, uploads.localhost, www.localhost, etc

---
Updated
---

Conversation on developer mailing list resulted in decision to reopen and accept ticket. The conversation turned up that this behavior is spec compliant per https://tools.ietf.org/html/rfc6761#section-6.3

Change History (3)

comment:1 by Carlton Gibson, 5 years ago

Resolution: needsinfo
Status: newclosed

Interesting. Currently we have, in HttpRequest.get_host():

        # Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
        allowed_hosts = settings.ALLOWED_HOSTS
        if settings.DEBUG and not allowed_hosts:
            allowed_hosts = ['localhost', '127.0.0.1', '[::1]']

Can I ask you to post to the DevelopersMailingList to canvas opinion? Assuming no blockers are raised it seems reasonable enough... (Reopen if accepted there.)

Last edited 5 years ago by Carlton Gibson (previous) (diff)

comment:2 by thenewguy, 5 years ago

For reference, the conversation chain has been started: https://groups.google.com/forum/#!topic/django-developers/xcoAF9Gm_dI

comment:3 by thenewguy, 5 years ago

Description: modified (diff)
Easy pickings: set
Resolution: needsinfo
Status: closednew
Triage Stage: UnreviewedAccepted
Note: See TracTickets for help on using tickets.
Back to Top