Tallboy
Tallboy

Reputation: 13467

Rails 6 - InvalidAuthenticityToken on Heroku

I've seen no answers on SO so far that don't answer this without suggesting to just disable it (which I don't want to do).

Locally, everything works, but deployed to producton on Heroku I'm getting InvalidAuthenticityToken.

From everything I can see, everything is set up properly.

I considered it maybe is because of this in ApplicationController:

before_action :authenticate

however it seems that prepend: true is no longer set within the application controller...

I tried overriding it anyway by just adding it (even though it's not there by default and it still doesnt work if I add this above the before_action line)

protect_from_forgery with: :exception, prepend: true

Edit I'll also say the fixed Sidekiq showing forbidden when trying to issue DELETE commands as well (kill job button)

Upvotes: 6

Views: 782

Answers (1)

cdadityang
cdadityang

Reputation: 543

Try adding config.force_ssl = true in your config/environments/production.rb and make sure your SSL is configured properly like you said switching to Full SSL instead of Flexible.

Upvotes: 5

Related Questions