8000 Add csrf origin for codespaces by pamelafox · Pull Request #8 · github/codespaces-django · GitHub
[go: up one dir, main page]

Skip to content

Add csrf origin for codespaces #8

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

Merged
merged 1 commit into from
Nov 18, 2022
Merged

Conversation

pamelafox
Copy link
Contributor

Purpose

Currently, due to the way Codespace "local" URLs work, it's not possible to log in to the Django admin panel. A CSRF error displays instead.

This PR overrides CSRF_TRUSTED_ORIGINS when the app is using the development settings and when an environment variable is present that indicates its running in Codespaces.

How to Test

Both in Codespaces and locally:

  • python manage.py createsuperuser
  • python manage.py runserver
  • Try logging into /admin with your superuser credentials. It won't work in the embedded browser since that seems to disable cookies. However, it should work if you pop it out.

Copy link
Collaborator
@joshaber joshaber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! ⚡

@joshaber joshaber merged commit 52723e0 into github:main Nov 18, 2022
@pamelafox pamelafox deleted the fix-csrf branch November 18, 2022 13:47
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
0