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
environment:
- MAX_CONCURRENT_SESSIONS=5
- PREBOOT_CHROME=true
- KEEP_ALIVE=true
- CONNECTION_TIMEOUT=300000
restart: always

View file

@ -36,7 +36,7 @@ export function ReceiptGenerator({
const url = window.URL.createObjectURL(blob);
const link = document.createElement("a");
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);
link.click();
link.remove();

View file

@ -283,7 +283,7 @@ export const whIntentSucceededHandler = async ({
to: "web@infoalloggi.it",
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: {
type: "ricevuta_cortesia",

View file

@ -171,24 +171,32 @@ const puppeteerGenPdf = async ({
try {
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 productionDomain = new URL(env.INTERNAL_BASE_URL).hostname;
const newCookies = [
{
name: TOKEN_CONFIG.OVERRIDE_TOKEN_COOKIE_NAME,
value: env.EXP_API_PASS,
domain:
env.NODE_ENV === "production"
? productionDomain
: "host.docker.internal",
path: "/",
},
];
await browser.setCookie(...newCookies);
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 newCookies = [
{
name: TOKEN_CONFIG.OVERRIDE_TOKEN_COOKIE_NAME,
value: env.EXP_API_PASS,
domain:
env.NODE_ENV === "production"
? productionDomain
: "host.docker.internal",
path: "/",
},
];
await browser.setCookie(...newCookies);
}
const baseUrl =
env.NODE_ENV === "production"

View file

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