3

I'm working with a Rails 4 API backend and a mobile app in both Android in iOS. Using Nginx and Unicorn.

To obtain certain data, the cliens must send me (among other things) a user id in the request's headers. We're using a custom header, for example WWW_CUSTOM_NAME, explained here. I'm aware that in Rails 4, I can capture the value in these custom headers by doing something like

request.headers["HTTP_WWW_CUSTOM_NAME"]

Indeed, this worked every single time my team and I worked in development. But when we pushed the code to the production server, the approach didn't work.

It's almost like the custom header is gone in production. I tried the same thing without the extra "HTTP_", removing capitals letter, and nothing worked. But in development works okay.

Any idea why this must be?

Community
  • 1
  • 1
Sebastialonso
  • 1,277
  • 16
  • 31

1 Answers1

12

If you are using nginx, this could be your problem

You have two options

  1. Change your custom header to use X-WWW-CUSTOM-NAME
  2. Turn on underscores_in_headers

First option would be better I think

usha
  • 28,179
  • 5
  • 69
  • 91