themarshallproject / klaxon

Klaxon enables reporters and editors to monitor scores of sites on the web for newsworthy changes.
https://newsklaxon.org
MIT License
646 stars 199 forks source link

Keep getting "Can't verify CSRF token authenticity" error using Docker #579

Closed razvansadeanu closed 2 years ago

razvansadeanu commented 2 years ago

This error has been bothering me for a few days, to give some context, I try to run klaxon locally using Docker but every time I try to log in using ADMIN_EMAIL I get error 422 ( Can't verify CSRF token authenticity. ActionController::InvalidAuthenticityToken (ActionController ::InvalidAuthenticityToken). To reproduce the error:

env_local.list looks like this: DATABASE_URL=postgres://postgres:<my-pass>@db/klaxon ADMIN_EMAILS=admin@news.org RAILS_ENV=production SECRET_KEY_BASE=<my-secret-key> SMTP_PROVIDER=SENDGRID SENDGRID_USERNAME=apikey SENDGRID_PASSWORD=<my-sendgrid-key> MAILER_FROM_ADDRESS=neghy1997@gmail.com KLAXON_FORCE_SSL=false KLAXON_COMPILE_ASSETS=true

Important to mention:

My questions:

immewnity commented 2 years ago

Try using master instead of develop - the develop branch is currently broken. I'm not sure if this'll fix your issue, but at the very least, will prevent other issues from occurring.

razvansadeanu commented 2 years ago

@immewnity thank you for quick answer, unfortunately, the same error on the master branch

razvansadeanu commented 2 years ago

The source of the error in my case was because I was NOT in an HTTPS environment. To fix the problem, I added traefik to the docker-compose file, here is a suggestive link