You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to rewrite the Host header when we make API calls to
localhost:8001 and localhost:8002 from the test suite, since the URLs
need to be resolvable from container-to-container.
However, the previous setup broke the local docker-compose setup for
login to the admin because the cookie domain is set to the internal
service names, so logging in was no longer possible due to a missing
csrftoken cookie (as we log in on localhost, not the internal
service names).
Only overwriting the Host header in /api/ subpaths is a pragmatic
approach that should solve this, since CSRF cookies are not used in
the API.
Furthermore, the browser sends an Oigin header of localhost:800x,
but this is different from the Host seen by Django due to the
proxy_pass directive, which also results in CSRF issues. The solution
is to enable X-Forwarded-Host header and calculate it in nginx, so
that it matches. For this match to happen, we also need to add the
port number and keep the mapped docker-compose port and nginx server
block ports in sync, since different ports lead to different origins.
0 commit comments