fix: update PDF filename format to replace spaces with dashes and enhance Puppeteer service configuration

This commit is contained in:
Marco Pedone 2026-03-10 12:36:11 +01:00
parent 70c1902a36
commit a09fa0597d
5 changed files with 29 additions and 17 deletions

View file

@ -38,6 +38,8 @@ services:
- "8081:3000" # Optional: Access the debug dashboard at localhost:8080 - "8081:3000" # Optional: Access the debug dashboard at localhost:8080
environment: environment:
- MAX_CONCURRENT_SESSIONS=5 - MAX_CONCURRENT_SESSIONS=5
- PREBOOT_CHROME=true
- KEEP_ALIVE=true
- CONNECTION_TIMEOUT=300000 - CONNECTION_TIMEOUT=300000
restart: always restart: always

View file

@ -36,7 +36,7 @@ export function ReceiptGenerator({
const url = window.URL.createObjectURL(blob); const url = window.URL.createObjectURL(blob);
const link = document.createElement("a"); const link = document.createElement("a");
link.href = url; link.href = url;
link.download = `ricevuta-cortesia-${data.clienteNome}-${format(data.date, "dd-MM-yyyy")}.pdf`; link.download = `ricevuta-cortesia-${data.clienteNome.replace(/\s+/g, "-")}-${format(data.date, "dd-MM-yyyy")}.pdf`;
document.body.appendChild(link); document.body.appendChild(link);
link.click(); link.click();
link.remove(); link.remove();

View file

@ -283,7 +283,7 @@ export const whIntentSucceededHandler = async ({
to: "web@infoalloggi.it", to: "web@infoalloggi.it",
attachments: [ attachments: [
{ {
filename: `ricevuta_cortesia_${utente.username}-${format(ordine.created_at, "dd-MM-yyyy")}.pdf`, filename: `ricevuta_cortesia_${utente.username.replace(/\s+/g, "-")}-${format(ordine.created_at, "dd-MM-yyyy")}.pdf`,
generate: { generate: {
type: "ricevuta_cortesia", type: "ricevuta_cortesia",

View file

@ -171,24 +171,32 @@ const puppeteerGenPdf = async ({
try { try {
browser = await puppeteer.connect({ browser = await puppeteer.connect({
browserWSEndpoint: env.BROWSER_WS_URL, browserWSEndpoint: `${env.BROWSER_WS_URL}?--user-data-dir=/tmp/session-0`,
}); });
const page = await browser.newPage(); const page = await browser.newPage();
const productionDomain = new URL(env.INTERNAL_BASE_URL).hostname; const c = await browser.cookies();
const newCookies = [ if (
{ c.length === 0 ||
name: TOKEN_CONFIG.OVERRIDE_TOKEN_COOKIE_NAME, !c.some(
value: env.EXP_API_PASS, (cookie) => cookie.name === TOKEN_CONFIG.OVERRIDE_TOKEN_COOKIE_NAME,
domain: )
env.NODE_ENV === "production" ) {
? productionDomain const productionDomain = new URL(env.INTERNAL_BASE_URL).hostname;
: "host.docker.internal", const newCookies = [
path: "/", {
}, name: TOKEN_CONFIG.OVERRIDE_TOKEN_COOKIE_NAME,
]; value: env.EXP_API_PASS,
await browser.setCookie(...newCookies); domain:
env.NODE_ENV === "production"
? productionDomain
: "host.docker.internal",
path: "/",
},
];
await browser.setCookie(...newCookies);
}
const baseUrl = const baseUrl =
env.NODE_ENV === "production" env.NODE_ENV === "production"

View file

@ -104,7 +104,9 @@ services:
- 3000 - 3000
environment: environment:
- MAX_CONCURRENT_SESSIONS=5 - MAX_CONCURRENT_SESSIONS=5
- CONNECTION_TIMEOUT=30000 - PREBOOT_CHROME=true
- KEEP_ALIVE=true
- CONNECTION_TIMEOUT=300000
restart: always restart: always
backend: backend: