Troubleshooting

장고 https적용시 CSRF에러

Wibaek 2023. 9. 4. 21:11
728x90

문제상황: 장고 서버를 https 보안연결로 배포했을때 admin페이지 로그인시에 CSRF에러가 발생하는 문제를 겪었다.

 

처음에는 Mixed content랑 순간적으로 햇갈려 http를 자동으로 https로 연결하게 수정했다. 어짜피 해야될 일이였어서 나쁘진 않았다.

 

이후 여러모로 찾아봐도 안나오다가 찾은것이 settings.py에 CSRF_TRUSTED_ORIGINS를 설정해주는 것이었다. 이것으로 문제 해결.

4.0부터 추가된 기능인듯?

 

https://stackoverflow.com/questions/70285834/forbidden-403-csrf-verification-failed-request-aborted-reason-given-for-fail

 

Forbidden (403) CSRF verification failed. Request aborted. Reason given for failure: Origin checking failed does not match any t

Help Reason given for failure: Origin checking failed - https://praktikum6.jhoncena.repl.co does not match any trusted origins. In general, this can occur when there is a genuine Cross Site Request

stackoverflow.com

 

728x90