Integrating an API Key to every request

Recently I’ve got a request to use a custom API that requires its customers to provide an API key value in every request. So the existing Ember app used apiHost value set up in application.js adapter:

# adapters/application.js

onst { JSONAPIAdapter } = DS;

export default JSONAPIAdapter.extend(DataAdapterMixin, {
  host: config.apiHost,

So, in development mode I passed in the API host with proxy option as follows:

 ember s --proxy=http://localhost:3000

In other environments, I used *env.deploy.<environment> files to keep the corresponding environment values, setting them in environment.js as follows:

if (deployTarget === 'staging') {
    ENV.clientID = process.env.OAUTH_CLIENT_ID;
    ENV.oauthUrl = process.env.OAUTH_URL;
    ENV.client_secret = process.env.OAUTH_CLIENT_SECRET;
    ENV.apiHost = process.env.API_HOST;

Any idea how is it possible to integrate an API key value in the header of every request? I didn’t find anything in available options.

You can specify headers on your adapter, which can be a computed property:

Thank you for your response. I wonder if by overriding it as it is indicated in the Docs example:

headers: computed(function() {
    return {
      'API_KEY': 'secret key',
      'ANOTHER_HEADER': 'Some header value'

will not erase already existing values, like Authorization, etc.