backstage / community-plugins

Community plugins for Backstage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› xcmetrics: Use authenticated request towards proxy backend

Rugvip opened this issue Β· comments

Plugin Name

xcmetrics

πŸ“œ Description

There's an incoming change to the @backstage/plugin-proxy-backend to require all requests to be authenticated by default. This means that plugins that rely on the proxy backend now need to start passing a Backstage user token in their requests.

πŸ‘ Expected behavior

The FetchApi should be used to make the request, for example like this:

const apiUrl = `${await this.discoveryApi.getBaseUrl('proxy')}/puppetdb`;
const response = await this.fetchApi.fetch(
`${apiUrl}${path}?${new URLSearchParams(query).toString()}`,
{
headers: {
'Content-Type': 'application/json',
},
},
);
if (response.ok) {
return (await response.json()) as T;
}
throw await ResponseError.fromResponse(response);

πŸ‘Ž Actual Behavior with Screenshots

Plain fetch API is used without credentials:

const response = await fetch(`${baseUrl}${path}`);

πŸ‘Ÿ Reproduction steps

Inspect the request to the proxy plugin in the network tab, If working correctly there should be an Authorization header present.

πŸ“ƒ Provide the context for the Bug.

Incoming change through backstage/backstage#24643

πŸ‘€ Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Are you willing to submit PR?

No, I don't have time to work on this right now

Example implementation PR for inspiration: #427