DEV Community

Ben Segni
Ben Segni

Posted on

Best way to serve a private API Key from a CMS

Just a quick question.

I have an angular web app which uses OneSignal to post notifications to a mobile app. Works great, but there is a one issue...

I have a private api key for authorisation from OneSignal in the headers of a service for onesignal and this is really bad, i know...

I can store the private key on the cms I have and this api endpoint is private to the public. You can only access it after login.

Could anyone recommend a good way of bringing a value into a service say from a component or another service, so I have set the httpOptions to something like?

const httpOptions = {
headers: new HttpHeaders({
"Content-Type": "application/json; charset=utf-8",
"Authorization": value.from_other_component_or_service //this is the value from the endpoint on the server.
})
}

Sorry if this is the wrong place to put these types of questions. This is my first post, so direct me to the right place if I've put this in the wrong feed.

Cheers.

Top comments (0)