403 error when running Django 4.0 on localhost

Hey.

Im running Django with Gunicorn and Nginx on a Proxmox Server (actually i got 3 different instances of Django, all with seperate IP’s). Since updating to Django 4.0 i get “Origin checking failed - http://192.168.69.68 does not match any trusted origins.” when logging in.
I searched for the issue but i dont know how to setup things right. I access the server with http://192.168.69.68 (no https because the server is not connected to the www). My allowed hosts are set to localhost.

See Settings | Django documentation | Django

Do i need to set CSRF_TRUSTED_ORIGINS to 192.168.69.68 ? I need CSRF_TRUSTED_ORIGINS to be set dynamically to the ip of the server.

You could probably do something where the entries for CSRF_TRUSTED_ORIGINS are set from an environment variable. Or you could get the address(es) in code in your settings file and create the list dynamically.

Or, you could disable the CSRF protection and hope that no one with access to your server also accesses a site that happens to contain a CSRF exploit to attack your server.

Or you could create your own internal dynamic DNS environment and allow that server to be addressed by name