#Read app-config.yaml setting at Custom Field Extensions.

18 messages · Page 1 of 1 (latest)

normal flicker
#

I am not able to read the value with this config:

import { useApi, configApiRef } from '@backstage/core-plugin-api';
const config = useApi(configApiRef);
const token = config.getString('secrets.token');

Is this ok ? Or I am missing something.

keen sedge
normal flicker
#

I tried to create the config.d.ts file into package/app. The I edit the package.json to add
{
// ...
"files": [
// ...
"config.d.ts"
],
"configSchema": "config.d.ts"
}

But it does not work.

keen sedge
#

Can you share the config.d.ts ?

normal flicker
#
export interface Config {
    /**
     * Visible in frontend and backend
     * @visibility frontend
     */
  secrets: {
      token: string;
  };
}
#

Now, I added this file and the package.json into the custom field extension that I created. But the problem persists.

keen sedge
#

You need to add visibility to the token as well, it's need on each property

normal flicker
#

I added:
visibility: frontend

keen sedge
#

Did that work?

normal flicker
#

No

#

where should create teh file config.d.ts ? into teh package/app ?

keen sedge
#

So it looks like this and it still doesn't work?

export interface Config {
  /**
   * Visible in frontend and backend
   * @visibility frontend
   */
  secrets: {
    /**
     * Visible in frontend and backend
     * @visibility frontend
     */
    token: string,
  };
}
normal flicker
#

yes, it does not work

keen sedge
#

OK, then I don't have anything further to suggest sadly

normal flicker
#

@keen sedge where the config.d.ts should be keep ?

keen sedge
#

In packages/app as you mentioned should be fine.

normal flicker
#

it is working. I clean up and restart everything

#

Thank you @keen sedge