I have nodejs and nginx running i am sending an additional header in the API 'api_key' and its not received in req.headers
and req.get('api_key')
in nodejs i have bellow configuration file for nginx
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name mysite.com;
return 301 https://$host$request_uri;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:9102/;
proxy_set_header Host $http_host;
proxy_set_header api_key $http_api_key;
#proxy_set_header api_key 'Some Value'; works
proxy_redirect off;
}
}
If set the value of proxy_set_header api_key 'some value'
it works and headers are printed on console but the api_key
is subjected to change that's why i am using $http_api_key
so that whatever comes in api_key
custom header is received as it is sent from rest client. I have tried couple of solutions like proxy_set_header api_key $upstream_http_api_key;
but no help. I want to receive any custom header sent from rest client in nodejs.
By default, nginx
does not pass headers containing underscores.
Try:
underscores_in_headers on;
See this document for details.
Alternatively, use API-KEY
or X-API-KEY
instead of API_KEY
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With