fix: update PDF filename format to replace spaces with dashes and enhance Puppeteer service configuration
This commit is contained in:
parent
70c1902a36
commit
a09fa0597d
5 changed files with 29 additions and 17 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -171,11 +171,18 @@ 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 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 = [
|
||||
{
|
||||
|
|
@ -189,6 +196,7 @@ const puppeteerGenPdf = async ({
|
|||
},
|
||||
];
|
||||
await browser.setCookie(...newCookies);
|
||||
}
|
||||
|
||||
const baseUrl =
|
||||
env.NODE_ENV === "production"
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue