DEV Community

Ben Segni
Ben Segni

Posted on

3

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.

API Trace View

Struggling with slow API calls?

Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post →