Weblate:如何修复 Docker/Traefik 下的 'Origin checking failed - ... does not match any trusted origins.' 错误
问题
在 Weblate 上提交表单时——即任何 POST 请求(如在设置页面中)——你会看到以下错误消息:
weblate_csrf_error.txt
Keine Berechtigung
CSRF-Verifizierung fehlgeschlagen. Anfrage abgebrochen.
Grund für CSRF-Fehler: Origin checking failed - https://weblate.mydomain.com does not match any trusted origins.解决方案
在我的 Traefik / docker-compose 设置中(详见使用 docker-compose 和 Traefik 的 10 分钟 Weblate 部署),只需在 .env 文件中追加以下内容即可轻松修复:
.env
WEBLATE_SECURE_PROXY_SSL_HEADER=HTTP_X_FORWARDED_PROTO,https该 .env 文件会映射到 Docker 容器的 environment。
注意,我还设置了以下内容:
.env_example
WEBLATE_ALLOWED_HOSTS=*
WEBLATE_SITE_DOMAIN=weblate.mydomain.com
#WEBLATE_ENABLE_HTTPS= # 不要设置此项,因为 HTTPS 由反向代理提供这些配置可能也是正常运行的必要条件。
Check out similar posts by category:
Weblate
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow