feat(web,ui): per-provider git forge API base URL and detection URLs

Configure a default API base URL per git provider (github/gitlab/gitea)
in settings.json gitProviders, with GitHub Enterprise support (Octokit
baseUrl + device-flow web origin derived from the API base), and replace
the client-side custom-domains list with server-persisted detection URL
chips (SSH/HTTPS forms normalized to hosts). The configured API base host
auto-counts as a detection host. Settings round-trip through the existing
/api/config/settings sanitizer; the UI store hydrates from server settings
with a one-time localStorage migration.
This commit is contained in:
2026-08-17 09:55:11 +00:00
parent a87b3fd228
commit 0fc857959e
55 changed files with 1685 additions and 272 deletions
+4 -3
View File
@@ -237,7 +237,7 @@ export function registerGiteaRoutes(app, options = {}) {
app.get('/api/gitea/auth/status', async (_req, res) => {
try {
const { getGiteaAuth, getGiteaAuthAccounts, clearGiteaAuth } = await getGiteaLibraries();
const { getGiteaAuth, getGiteaAuthAccounts, clearGiteaAuth, getGiteaDefaultBaseUrl } = await getGiteaLibraries();
const auth = getGiteaAuth();
const accounts = getGiteaAuthAccounts();
if (!auth?.accessToken) {
@@ -261,6 +261,7 @@ export function registerGiteaRoutes(app, options = {}) {
connected: true,
...(user ? { user } : {}),
accounts,
defaultBaseUrl: getGiteaDefaultBaseUrl(),
});
} catch (error) {
console.error('Failed to get Gitea auth status:', error);
@@ -275,8 +276,8 @@ export function registerGiteaRoutes(app, options = {}) {
return res.status(400).json({ error: 'accessToken is required' });
}
const { normalizeBaseUrl, setGiteaAuth, getGiteaAuthAccounts } = await getGiteaLibraries();
const baseUrl = normalizeBaseUrl(req.body?.baseUrl);
const { normalizeBaseUrl, setGiteaAuth, getGiteaAuthAccounts, getGiteaDefaultBaseUrl } = await getGiteaLibraries();
const baseUrl = normalizeBaseUrl(req.body?.baseUrl) || getGiteaDefaultBaseUrl();
if (!baseUrl) {
return res.status(400).json({ error: 'baseUrl is required and must be a valid URL' });
}