Access-Control-Allow-Credentials Headers are set twice

170 views
Skip to first unread message

Mike Omondi

unread,
Oct 2, 2023, 12:06:30 PM10/2/23
to KrakenD Community
Krakend API gateway errors out but the request in the upstream service returns a status code of 200. This is due to Access-Control-Allow-Credentials headers being set twice. I don't know if is because both the API gateway sets this in the config file and express server sets this in the CORS middleware configuration. 

user panel - Browser console.PNG
API gateway - krakend.json config.PNG
user panel - Browser Network Tab.PNG

Albert Lombarte

unread,
Oct 11, 2023, 3:32:35 AM10/11/23
to KrakenD Community, mike.ted...@gmail.com
Hi,

You can block any headers from reaching your backend by adding a Martian modifier to the following extra configuration:

"backend": [
{
"url_pattern": "...",
"extra_config": {
"modifier/martian": {
"header.Blacklist": {
"scope": ["request"],
"names": ["Access-Control-Allow-Credentials"]
}
}
}

}
],

Hope this helps

El dia dilluns, 2 d’octubre de 2023 a les 18:06:30 UTC+2, mike.ted...@gmail.com va escriure:

Mike Omondi

unread,
Oct 11, 2023, 10:28:58 AM10/11/23
to KrakenD Community, Albert Lombarte, mike.ted...@gmail.com
I have tried adding the extra configuration for modifying the response headers using the Martian modifier but there is no effect, the headers still duplicate in the response. I don't understand why.
For example, as from the earlier request made when I want to refresh a token using this route it return a status of 200 OK but the error stops the request from redirecting to another page from the client side.

API gateway - krakend.json config [Header Modifier].PNG

Mike Omondi

unread,
Oct 11, 2023, 2:34:43 PM10/11/23
to KrakenD Community, Albert Lombarte, mike.ted...@gmail.com
Thanks for your reply.

Is there any other configurations that I am missing for setting up the Martian modifier? 

On Wednesday, October 11, 2023 at 10:32:35 AM UTC+3 Albert Lombarte wrote:
Reply all
Reply to author
Forward
0 new messages