Recipes
Data & Functions
Securely store and use a secret

Securely store and use a secret

Problem

You need to store a secret and access it securely without exposing it in the editor.

Solution

  1. Browse to the Configuration tab in the Dynaboard editor
  2. In the App Secrets panel, click the + button
  3. Name your secret (e.g. MY_API_KEY) and enter the secret into the value field below
  4. Your secret is now accessible in server-side resources using ${{ MY_API_KEY }}

Discussion

const myAPIKey = ${{ MY_API_KEY }}
const res = await fetch('https://httpbin.org/post', {
	method: 'POST',
  headers: {
		Authorization: 'Bearer ' + myAPIKey,
  }
})
 
const resBody = await res.json()
return resBody

See also