-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
403 Forbidden with CSRF verification failed, deploying at Google Cloud Run #7070
Comments
Hello, This error typically occurs when Label Studio’s Django CSRF protection doesn’t recognize requests from your Cloud Run URL. Although issue #6606 was originally reported for Kubernetes, the same solution applies to Cloud Run. Please try the following steps: 1. Set the CSRF_TRUSTED_ORIGINS Environment VariableUpdate your deployment to include this variable with your Cloud Run service URL. For example, if your service URL is:
You can update your Cloud Run deployment using the following command:
2. Remove Unnecessary Environment VariablesIf you’ve set 3. Verify HeadersCloud Run automatically manages forwarded headers (such as Let me know if this resolves the issue or if you need further assistance.
|
I know that is not recommended to turn off CSRF, but I manage to do it by setup: Similar to huggingface dockerfile. |
Hello, Could you please apply the following suggestion and let us know if it has helped you bypass this error> 1. Verify CSRF_TRUSTED_ORIGINS
Then you should set:
Double-check that the URL you use in your browser exactly matches this entry (including the https scheme). 2. Set Additional Proxy-Related VariablesWhen deploying behind a load balancer or proxy (as Cloud Run does), Django might require extra settings for forwarded headers. Please update your deployment to include these variables:
For example, your deployment command could look like this:
3. Confirm URL ConsistencyPlease check that the URL in your CSRF_TRUSTED_ORIGINS exactly matches the URL you use to access the service (no extra characters, trailing slashes, or mismatched schemes). Even a small difference can cause CSRF validation to fail. 4. Review Your Application LogsIt would be helpful to inspect the logs from your Cloud Run instance to see what “Origin” or “Referer” header values Django is receiving. This might reveal if the forwarded header values differ from what your CSRF_TRUSTED_ORIGINS variable expects. Please let me know if the above has resolved the issue!
|
Thank you, it worked! |
Great! we are happy to assist you! Please feel free to reach out if you need help! for now we will close this ticket.
|
Describe the bug
I want to deploy my own label-studio instance for research purposes. I have tried to deploy using the "quick button link" Google Cloud Run, located in README.md. The deployment works well, however I am unable to login; I am getting "Forbidden (403) CSRF verification failed. Request aborted."
It seems related to this issue #6606 . However they are using Google Cloud Kubernetes Engine and not Google Cloud Run.
To Reproduce
Steps to reproduce the behavior:
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context
Full Google Cloud Run log
The text was updated successfully, but these errors were encountered: