[英]How can I make all my header elements to go through nginx to my node js api
我正在從我的 vue js 應用程序發送一個帶有標題的請求
{
Access-Control-Allow-Headers: "Origin, Content-Type, X-Auth-Token"
Access-Control-Allow-Methods: "GET, POST, PATCH, PUT, DELETE, OPTIONS"
Access-Control-Allow-Origin: "*"
hotel_id: "custom-hotel-id-value-here"
token: "custom-token-value-here"
}
當它到達我的 digitalocean droplet 時,它會通過NGINX 。 在 node-express api 上記錄請求標頭時,它顯示了另一種沒有“hotel_id”元素的標頭格式,但我確實需要該標頭元素來繼續系統的適當功能。 這是在 node-express api 記錄的請求頭
{
'x-real-ip': '197.157.*.*',
'x-forwarded-for': '197.157.*.*',
'x-nginx-proxy': 'true',
host: '206.189.*.*:*',
connection: 'close',
'access-control-allow-origin': '*',
'access-control-allow-headers': 'Origin, Content-Type, X-Auth-Token',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
token: 'custom-token-value-here'
'access-control-allow-methods': 'GET, POST, PATCH, PUT, DELETE, OPTIONS',
accept: '*/*',
origin: 'http://206.189.*.*',
referer: 'http://206.189.*.*/',
'accept-encoding': 'gzip, deflate',
'accept-language': 'en-US,en;q=0.9'
}
在部署之前,它在本地計算機上運行良好。
經過我的研究,我發現標頭中的下划線不能通過 nginx,在這個例子中它是 'hotel_id'。 我需要添加
underscores_in_headers on;
在我的 nginx 服務器塊(上下文:http,服務器)中,因為它的默認值是
underscores_in_headers off;
有關更多信息,請點擊此鏈接https://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.