2022-06-24 Django 3.xから4.xへの更新でPOSTリクエスト時にCSRF検証に失敗する 下書き
投稿済み
settings.pyにCSRF_TRUSTED_ORIGINSを追加すればよい。
Origin: e.g. https://example.com
CSRF検証のドキュメントを3.xと比べると、以下の記述が増えている。
CsrfViewMiddleware verifies the Origin header, if provided by the browser, against the current host and the CSRF_TRUSTED_ORIGINS setting. This provides protection against cross-subdomain attacks.