Admin login creating CRSF verification failure

I have just started a new project, I created a superuser then tried to log into the admin panel. I just keep getting this error message. Cookies are definitely enabled in my browser. I’ve tried two different browsers, I get it with both.

You need to include your gitpod development server URL in the CSRF_TRUSTED_ORIGINS setting.

(The message could possibly be updated to cover this case.)

I haven’t used gitpod but I found this docs page and it suggests the GITPOD_WORKSPACE_URL var contains that value. Thus you can probably use:

import os

CSRF_TRUSTED_ORIGINS = []
if "GITPOD_WORKSPACE_URL" in os.environ:
    CSRF_TRUSTED_ORIGINS.append(os.environ["GITPOD_WORKSPACE_URL"])

Check if that works!

2 Likes

That’s brilliant, it did. Thanks very much :slight_smile: