Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask is not getting application specific headers added through javascript

I am adding application specific headers in my GET request. I am able to view the header in my Chrome's developer console. So it seems they are being sent to the server.

The header is chart_type

enter image description here

But, when I try to access the headers in my flask application it, is missing from request.headers

The output of request.headers is below:

X-Forwarded-For: 127.0.0.1
Host: localhost
X-Nginx-Proxy: true
Connection: close
Pragma: no-cache
Cache-Control: no-cache
Sec-Ch-Ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"
Sec-Ch-Ua-Mobile: ?0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Sec-Ch-Ua-Platform: "macOS"
Accept: */*
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:8080/stock-market-pattern-modelling/quote?symbol=AAPL
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
like image 628
Pawan Avatar asked Oct 18 '25 08:10

Pawan


1 Answers

While underscores are allowed in header names, some server implementations silently drop headers with underscores in the name.

For instance Nginx with the default configuration will ignore headers with underscore in the name (see underscores_in_headers and ignore_invalid_headers documentation).

I therefore suggest that you try the header name Chart-Type instead of chart_type.

like image 99
codeape Avatar answered Oct 21 '25 00:10

codeape