feat(templates): add custom base URL support for template management

- Implement dynamic base URL configuration for template fetching
- Add localStorage persistence for base URL
- Update template rendering to use dynamic base URL
- Modify API routes to support optional base URL parameter
- Enhance template browsing flexibility
This commit is contained in:
Mauricio Siu
2025-03-09 14:08:08 -06:00
parent 6e7e7b3f9a
commit 6def84d456
3 changed files with 100 additions and 99 deletions

View File

@@ -54,7 +54,7 @@ interface TemplateMetadata {
*/
export async function fetchTemplatesList(
baseUrl = "https://dokploy.github.io/templates",
): Promise<CompleteTemplate[]> {
): Promise<TemplateMetadata[]> {
try {
const response = await fetch(`${baseUrl}/meta.json`);
if (!response.ok) {
@@ -62,22 +62,13 @@ export async function fetchTemplatesList(
}
const templates = (await response.json()) as TemplateMetadata[];
return templates.map((template) => ({
metadata: {
id: template.id,
name: template.name,
description: template.description,
version: template.version,
logo: template.logo,
links: template.links,
tags: template.tags,
},
// These will be populated when fetching individual templates
variables: {},
config: {
domains: [],
env: {},
mounts: [],
},
id: template.id,
name: template.name,
description: template.description,
version: template.version,
logo: template.logo,
links: template.links,
tags: template.tags,
}));
} catch (error) {
console.error("Error fetching templates list:", error);