Canvas: Support template variables in base URL of actions (#91227)

This commit is contained in:
Nathan Marrs 2024-07-30 18:21:57 -06:00 committed by GitHub
parent 0a34b51055
commit a71dfd3109
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,7 +12,8 @@ type IsLoadingCallback = (loading: boolean) => void;
export const callApi = (api: APIEditorConfig, updateLoadingStateCallback?: IsLoadingCallback) => {
if (api && api.endpoint) {
// If API endpoint origin matches Grafana origin, don't call it.
if (requestMatchesGrafanaOrigin(api.endpoint)) {
const interpolatedUrl = interpolateVariables(api.endpoint);
if (requestMatchesGrafanaOrigin(interpolatedUrl)) {
appEvents.emit(AppEvents.alertError, ['Cannot call API at Grafana origin.']);
updateLoadingStateCallback && updateLoadingStateCallback(false);
return;