Skip to content

Fix get_subdomain() redirect loop on apex domains#2121

Open
mhingston wants to merge 1 commit into
samuelclay:mainfrom
mhingston:fix/get-subdomain-apex-domain
Open

Fix get_subdomain() redirect loop on apex domains#2121
mhingston wants to merge 1 commit into
samuelclay:mainfrom
mhingston:fix/get-subdomain-apex-domain

Conversation

@mhingston

@mhingston mhingston commented Jul 1, 2026

Copy link
Copy Markdown

Problem

get_subdomain() in apps/reader/views.py naively splits the hostname on dots and returns the first segment. For apex domains like newsblur.yourdomain.com (which contain 2+ dots), it incorrectly returns newsblur as a subdomain. Since newsblur isn't in ALLOWED_SUBDOMAINS and doesn't match any username, it redirects to the same URL — causing an infinite redirect loop.

Fix

Use request.subdomain from the SubdomainMiddleware instead, which properly parses subdomains against the Site domain and returns None for apex domains. Falls back to the old logic only when the middleware hasn't set the attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant