Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx is ignoring my headers

I'm working with apache on my local instance and nginx on production.

I have a javascript application that is setting headers in API calls to authenticate the user. It's working fine on local with my apache server. However for some reason, my custom headers are ignored by Nginx.

I tried to add this line in my site configuration:

add_header 'Access-Control-Allow-Origin' '*';

But it still ignore the headers. Does anyone know where I should look to bypass this ?

Cheers, Maxime

like image 775
maxwell2022 Avatar asked Mar 20 '23 09:03

maxwell2022


1 Answers

I found what was the issue.

My custom headers were API_USER and API_TOKEN. There is a directive in Nginx that says to ignore headers with a '_' in the name, more info here

So I've updated my custom headers to x-api-user and x-api-token and now it's working like a charm !

like image 130
maxwell2022 Avatar answered Mar 28 '23 09:03

maxwell2022