A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix localhost translation logic in printer service
Amruth Pillaid0a174d7b7e0
diff --git a/apps/server/src/printer/printer.service.ts b/apps/server/src/printer/printer.service.tsindex 74b2fcef3..fa06b6132 100644--- a/apps/server/src/printer/printer.service.ts+++ b/apps/server/src/printer/printer.service.ts@@ -104,14 +104,19 @@ export class PrinterService {if ([publicUrl, storageUrl].some((url) => /https?:\/\/localhost(:\d+)?/.test(url))) {// Switch client URL from `http[s]://localhost[:port]` to `http[s]://host.docker.internal[:port]` in development// This is required because the browser is running in a container and the client is running on the host machine.- url = url.replace(/localhost(:\d+)?/, "host.docker.internal");-+ url = url.replace(+ /localhost(:\d+)?/,+ (_match, port) => `host.docker.internal${port ?? ""}`,+ );+await page.setRequestInterception(true);// Intercept requests of `localhost` to `host.docker.internal` in developmentpage.on("request", (request) => {if (request.url().startsWith(storageUrl)) {- const modifiedUrl = request.url().replace(/localhost(:\d+)?/, "host.docker.internal");+ const modifiedUrl = request+ .url()+ .replace(/localhost(:\d+)?/, (_match, port) => `host.docker.internal${port ?? ""}`);void request.continue({ url: modifiedUrl });} else {@@ -220,17 +225,19 @@ export class PrinterService {let url = publicUrl;- if ([publicUrl, storageUrl].some((url) => url.includes("localhost"))) {- // Switch client URL from `localhost` to `host.docker.internal` in development+ if ([publicUrl, storageUrl].some((url) => /https?:\/\/localhost(:\d+)?/.test(url))) {+ // Switch client URL from `http[s]://localhost[:port]` to `http[s]://host.docker.internal[:port]` in development// This is required because the browser is running in a container and the client is running on the host machine.- url = url.replace("localhost", "host.docker.internal");+ url = url.replace(/localhost(:\d+)?/, (_match, port) => `host.docker.internal${port ?? ""}`);await page.setRequestInterception(true);// Intercept requests of `localhost` to `host.docker.internal` in developmentpage.on("request", (request) => {if (request.url().startsWith(storageUrl)) {- const modifiedUrl = request.url().replace("localhost", `host.docker.internal`);+ const modifiedUrl = request+ .url()+ .replace(/localhost(:\d+)?/, (_match, port) => `host.docker.internal${port ?? ""}`);void request.continue({ url: modifiedUrl });} else {