Reputation: 2466
I have an app I recently upgraded to Rails 4.2.0. In this app I request an access token for a small API. In the API controller I am attempting to grab this token. I am testing with POSTman, sending a request to my local machine, running it with dev or production works perfect fine. Sending a request to the nginx phusion passenger server yields nothing, the token is nil according to the logs.
POSTman request
headers: access_token: '12345'
API controller
@access_token = request.headers['HTTP_ACCESS_TOKEN']
The headers are read in all cap with the http prefix as I read somewhere - which I can't seem to find now, that this was the proper setup. My rails 3.2 app used to read lowercase without the prefix headers, and work correctly. Once upgrading to 4.2.0, this functionality broke locally. Adding the prefix and uppercasing the read-in solved the issue locally in dev and production modes. Once deployed, however, the headers always seem to be nil.
Since I can run locally in production mode and this works, I am having a hard time figuring out what happens once this is deployed. Is this something with nginx or passenger? I am pretty new to nginx, am I missing something here? Any help you could provide would be greatly appreciated.
Upvotes: 0
Views: 705
Reputation: 530
When using rails over an Webserver with CGI Interface, these Headers are dropped by Apache or NGIX. It's a legacy problem. ACCESS-TOKEN and ACCESS_TOKEN would be mapped to the same CGI variable 'access_token'. And because Dashes are more common in the header, the underscores are ignored.
Upvotes: 2