diff --git a/apps/api/devTemplates.yaml b/apps/api/devTemplates.yaml index e77a57839..505abfb60 100644 --- a/apps/api/devTemplates.yaml +++ b/apps/api/devTemplates.yaml @@ -1892,8 +1892,8 @@ - '9001' proxy: - port: '9000' - - port: '9001' domain: $$coolify_fqdn_minio_console + - port: '9001' variables: - id: $$coolify_fqdn_minio_console name: MINIO_SERVER_URL diff --git a/apps/api/src/routes/api/v1/handlers.ts b/apps/api/src/routes/api/v1/handlers.ts index adfad042a..e99cb3f61 100644 --- a/apps/api/src/routes/api/v1/handlers.ts +++ b/apps/api/src/routes/api/v1/handlers.ts @@ -41,10 +41,14 @@ export async function cleanupManually(request: FastifyRequest) { export async function refreshTemplates() { try { const { default: got } = await import('got') - let templates = {} try { - const response = await got.get('https://get.coollabs.io/coolify/service-templates.yaml').text() - templates = yaml.load(response) + if (isDev) { + const response = await fs.readFile('./devTemplates.yaml', 'utf8') + await fs.writeFile('./template.json', JSON.stringify(yaml.load(response), null, 2)) + } else { + const response = await got.get('https://get.coollabs.io/coolify/service-templates.yaml').text() + await fs.writeFile('/app/template.json', JSON.stringify(yaml.load(response), null, 2)) + } } catch (error) { throw { status: 500, @@ -52,11 +56,6 @@ export async function refreshTemplates() { }; } - if (isDev) { - await fs.writeFile('./template.json', JSON.stringify(templates, null, 2)) - } else { - await fs.writeFile('/app/template.json', JSON.stringify(templates, null, 2)) - } return {}; } catch ({ status, message }) { return errorHandler({ status, message }); diff --git a/apps/api/src/routes/webhooks/traefik/handlers.ts b/apps/api/src/routes/webhooks/traefik/handlers.ts index 5dac66235..58e45e416 100644 --- a/apps/api/src/routes/webhooks/traefik/handlers.ts +++ b/apps/api/src/routes/webhooks/traefik/handlers.ts @@ -20,7 +20,7 @@ function generateLoadBalancerService(id, port) { function generateHttpRouter(id, nakedDomain, pathPrefix) { return { entrypoints: ['web'], - rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`)) && PathPrefix(\`${pathPrefix}\`)`, + rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`))${pathPrefix ? `&& PathPrefix(\`${pathPrefix}\`)` : ''}`, service: `${id}`, middlewares: [] } @@ -29,7 +29,7 @@ function generateProtocolRedirectRouter(id, nakedDomain, pathPrefix, fromTo) { if (fromTo === 'https-to-http') { return { entrypoints: ['websecure'], - rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`)) && PathPrefix(\`${pathPrefix}\`)`, + rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`))${pathPrefix ? `&& PathPrefix(\`${pathPrefix}\`)` : ''}`, service: `${id}`, tls: { domains: { @@ -41,7 +41,7 @@ function generateProtocolRedirectRouter(id, nakedDomain, pathPrefix, fromTo) { } else if (fromTo === 'http-to-https') { return { entrypoints: ['web'], - rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`)) && PathPrefix(\`${pathPrefix}\`)`, + rule: `(Host(\`${nakedDomain}\`) || Host(\`www.${nakedDomain}\`))${pathPrefix ? `&& PathPrefix(\`${pathPrefix}\`)` : ''}`, service: `${id}`, middlewares: ['redirect-to-https'] }; @@ -409,7 +409,7 @@ export async function traefikConfiguration(request, reply) { } } for (const service of data.services) { - let { id, fqdn, dualCerts, configuration: { port, pathPrefix = '/', domain: customDomain }, isCustomSSL = false } = service + let { id, fqdn, dualCerts, configuration: { port, pathPrefix, domain: customDomain }, isCustomSSL = false } = service if (customDomain) { fqdn = customDomain }