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.