Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: Proxy

Andras Bacsai08704c289a1e
diff --git a/src/lib/haproxy/configuration.ts b/src/lib/haproxy/configuration.ts
index f93a34838f..8a967befd0 100644
--- a/src/lib/haproxy/configuration.ts
+++ b/src/lib/haproxy/configuration.ts
@@ -1,6 +1,8 @@
import { dev } from '$app/env';
import got, { type Got } from 'got';
import * as db from '$lib/database';
+import mustache from 'mustache';
+import crypto from 'crypto';
import { checkContainer, checkHAProxy } from '.';
import { asyncExecShell, getDomain, getEngine } from '$lib/common';
import { supportedServiceTypesAndVersions } from '$lib/components/common';
@@ -262,36 +264,20 @@ export async function configureHAProxy(): Promise<void> {
redirectValue,
redirectTo: isWWW ? domain.replace('www.', '') : 'www.' + domain
});
- for (const service of services) {
- const { fqdn, id, type, destinationDocker, destinationDockerId, updatedAt } = service;
- if (destinationDockerId) {
- const { engine } = destinationDocker;
- const found = supportedServiceTypesAndVersions.find((a) => a.name === type);
- if (found) {
- const port = found.ports.main;
- const publicPort = service[type]?.publicPort;
- const isRunning = await checkContainer(engine, id);
- if (fqdn) {
- const domain = getDomain(fqdn);
- const isHttps = fqdn.startsWith('https://');
- const isWWW = fqdn.includes('www.');
- const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`;
- if (isRunning) {
- data.services.push({
- id,
- port,
- publicPort,
- domain,
- isRunning,
- isHttps,
- redirectValue,
- redirectTo: isWWW ? domain.replace('www.', '') : 'www.' + domain,
- updatedAt: updatedAt.getTime()
- });
- }
- }
- }
+ }
+ const output = mustache.render(template, data);
+ const newHash = crypto.createHash('md5').update(output).digest('hex');
+ const { proxyHash, id } = await db.listSettings();
+ if (proxyHash !== newHash) {
+ await db.prisma.setting.update({ where: { id }, data: { proxyHash: newHash } });
+ await haproxy.post(`v2/services/haproxy/configuration/raw`, {
+ searchParams: {
+ skip_version: true
+ },
+ body: output,
+ headers: {
+ 'Content-Type': 'text/plain'
}
- }
+ });
}
}
diff --git a/src/routes/destinations/[id]/index.json.ts b/src/routes/destinations/[id]/index.json.ts
index d64df8c08e..aa9be6aeab 100644
--- a/src/routes/destinations/[id]/index.json.ts
+++ b/src/routes/destinations/[id]/index.json.ts
@@ -8,7 +8,6 @@ import type { RequestHandler } from '@sveltejs/kit';
export const get: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event);
if (status === 401) return { status, body };
- console.log(teamId);
const { id } = event.params;
try {
const destination = await db.getDestination({ id, teamId });
diff --git a/src/routes/sources/[id]/newGithubApp.svelte b/src/routes/sources/[id]/newGithubApp.svelte
index b6a74c3bab..c8cb4f6f38 100644
--- a/src/routes/sources/[id]/newGithubApp.svelte
+++ b/src/routes/sources/[id]/newGithubApp.svelte
@@ -36,7 +36,6 @@
export let settings;
onMount(() => {
const { organization, id, htmlUrl } = source;
- console.log(source);
const { fqdn } = settings;
const host = dev
? 'http://localhost:3000'