Hi all,
I'm currently implementing a solution for a client using the ArcGIS Javascript API. The solution requires some security which requires API keys and custom headers. When I'm adding the API key in the request URL I'm not having any CORS issues, whenever I'm adding the API key in the header I'm getting CORS issues. Even when I add "Access-Control-Allow-Origin": '*' in my header I'm getting issues. Here is my code:
ngOnInit(): void {
config.request.interceptors?.push({
urls: "xyz",
headers: {
"Accept" :'/',
"Access-Control-Allow-Origin": '*',
"API-KEY" : "foo"
},
before: function(request) {
request.url = (<string>request.url).replace(AppConfig.settings.baseURL.url, AppConfig.settings.proxyURL.url)
console.log(request);
},
after: function(response) {
console.log(response);
}
})
}
This is the error:
Header has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response.
When I only add "Accept": '/' in my header I have no issues for example.
Can someone help me out?
Kind regards,
Nicolas