I solved the issue, it was actually much simpler than i thought.
First i had to change the http type to https, afterwards i had the CSRF token error.
To fix this issue, i had to replace the http type in the nginx config file for the website, forcing it to https. Here are the lines i changed:
proxy_set_header X-Forwarded-Proto https;