Skip to content

Allow custom-admin host in Astro dev server - #4856

Merged
marcoacierno merged 1 commit into
mainfrom
claude/django-admin-astro-host-54e77f
Nov 7, 2026
Merged

marcoacierno merged 1 commit into
mainfrom
claude/django-admin-astro-host-54e77f

Conversation

@EdAbati

@EdAbati EdAbati commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

What

With Docker Compose, /admin/login/ returns a 500:

HTTPError: 403 Client Error: Forbidden for url: http://127.0.0.1:8000/astro/admin-base.html

Django gets its admin base template from the Astro dev server at http://custom-admin:3002. Vite rejects that hostname because only localhost, *.localhost and IP addresses are allowed by default.

#4841 upgraded Astro from 5.0.5 to 7.4.4, which moved Vite from 6.0.3 to 8.3.5. The host check was added in Vite 6.0.9, so the old version didn't have it.

This only allows the Docker service name, and other hostnames still get a 403. Production isn't affected, because astro_proxy returns 404 when DEBUG is off.

Docs:

Testing: ran custom-admin and backend with Docker Compose. /admin/login/ went from 500 to 200, and a request to the Astro server with Host: evil.example still returns 403.

ToDo

Nothing left.

In local dev, /admin/login/ fails with a 500 because Django fetches its
admin base template from the Astro dev server at http://custom-admin:3002
and Vite answers 403 for that hostname.

The check came in with the Astro ^5.0.5 to ^7.4.4 upgrade in #4841, which
moved Vite from 6.0.3 to 8.3.5. Django connects using the Docker service
name, so that hostname has to be allowed. Only local dev is affected,
because astro_proxy returns 404 when DEBUG is off.
@vercel

vercel Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pycon Ready Ready Preview Nov 7, 2026 7:46am UTC

@EdAbati
EdAbati marked this pull request as ready for review November 7, 2026 07:46
@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.42%. Comparing base (a1e0b2b) to head (66c3be1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4856   +/-   ##
=======================================
  Coverage   92.42%   92.42%           
=======================================
  Files         360      360           
  Lines       10935    10935           
  Branches      949      949           
=======================================
  Hits        10107    10107           
  Misses        706      706           
  Partials      122      122           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marcoacierno
marcoacierno merged commit f0ebad5 into main Nov 7, 2026
9 checks passed
@marcoacierno
marcoacierno deleted the claude/django-admin-astro-host-54e77f branch November 7, 2026 15:48

This branch was successfully deployed

1 active deployment
Preview — 66c3be18 Deployed Nov 7, 2026 by vercel[bot]
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.

2 participants