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,11 +171,18 @@ 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 c = await browser.cookies();
if (
c.length === 0 ||
!c.some(
(cookie) => cookie.name === TOKEN_CONFIG.OVERRIDE_TOKEN_COOKIE_NAME,
)
) {
const productionDomain = new URL(env.INTERNAL_BASE_URL).hostname; const productionDomain = new URL(env.INTERNAL_BASE_URL).hostname;
const newCookies = [ const newCookies = [
{ {
@ -189,6 +196,7 @@ const puppeteerGenPdf = async ({
}, },
]; ];
await browser.setCookie(...newCookies); 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: