I'm running an app with Rails 5.2 in development mode on an nginx server. Everything works locally, but after I push it to my remote server and start the Rails server, I can't create, edit or delete records. I get a Rails error that says: "ActionController::InvalidAuthenticityToken"
Oddly this only happens when I'm using a Chrome browser. Everything works fine when in Firefox or Edge. These are the parameters that are sent with a delete request:
{"utf8"=>"✓",
"authenticity_token"=>"blahblahblah",
"service_line_item"=>{"title"=>"a", "body"=>""},
"commit"=>"create",
"service_id"=>"2",
"service_type"=>"1"}
As you can see there is clearly an authenticity token. And when I compare it to the token that loads in the HTML, it matches. All my forms use the form_for
helpers.
Here is the log from my server:
Started POST "/zoom/services/new-line-item?service_id=2&service_type=2" for 127.0.0.1 at 2019-01-25 22:55:42 +0000
Processing by ServicesController#new_line_item as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"blahblahblah", "service_line_item"=>{"title"=>"a", "body"=>""}, "commit"=>"create", "service_id"=>"2", "service_type"=>"1"}
HTTP Origin header (https://dev.mysite.com) didn't match request.base_url (http://localhost:3000)
Completed 422 Unprocessable Entity in 0ms (ActiveRecord: 0.0ms)
I've tried all the obvious things like reloading my server, deleting cookies and hard refreshing the page, but nothing works. Any help would be hugely appreciated.