diff --git a/.changeset/pink-spies-rule.md b/.changeset/pink-spies-rule.md new file mode 100644 index 0000000000..71653a1841 --- /dev/null +++ b/.changeset/pink-spies-rule.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-backend': patch +--- + +Replacing the hard coded `baseApiUrl` by reading the value from configuration to enable private GitHub setup for TechDocs. diff --git a/plugins/techdocs-backend/src/default-branch.ts b/plugins/techdocs-backend/src/default-branch.ts index 487f343d93..fe88ff1055 100644 --- a/plugins/techdocs-backend/src/default-branch.ts +++ b/plugins/techdocs-backend/src/default-branch.ts @@ -42,9 +42,11 @@ interface IGitlabBranch { }; } -function getGithubApiUrl(url: string): URL { +function getGithubApiUrl(config: Config, url: string): URL { const { protocol, owner, name } = parseGitUrl(url); - const apiBaseUrl = 'api.github.com'; + const apiBaseUrl = + config.getOptionalString('integrations.github.apiBaseUrl') || + 'api.github.com'; const apiRepos = 'repos'; return new URL(`${protocol}://${apiBaseUrl}/${apiRepos}/${owner}/${name}`); @@ -133,7 +135,7 @@ async function getGithubDefaultBranch( repositoryUrl: string, config: Config, ): Promise { - const path = getGithubApiUrl(repositoryUrl).toString(); + const path = getGithubApiUrl(config, repositoryUrl).toString(); const options = getGithubRequestOptions(config); try {