From 21c486c4df824ef7d2c0f7bdd14c63e82b6ce29f Mon Sep 17 00:00:00 2001 From: eryalito Date: Mon, 22 Jul 2024 12:22:09 +0200 Subject: [PATCH] Change max body size using envvars when rendering diagramas (#1761) --- diagrams.net/src/index.js | 2 +- excalidraw/src/index.js | 2 +- mermaid/src/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/diagrams.net/src/index.js b/diagrams.net/src/index.js index 460bbcd6d..673d6b778 100644 --- a/diagrams.net/src/index.js +++ b/diagrams.net/src/index.js @@ -19,7 +19,7 @@ import { SyntaxError, TimeoutError, Worker } from './worker.js' const url = new URL(req.url, 'http://localhost') // create a URL object. The base is not important here const outputType = url.pathname.match(/\/(png|svg)$/)?.[1] if (outputType) { - const diagramSource = await micro.text(req, { limit: '1mb', encoding: 'utf8' }) + const diagramSource = await micro.text(req, { limit: (process.env.KROKI_MAX_BODY_SIZE ?? '1mb'), encoding: 'utf8' }) if (diagramSource) { try { const isPng = outputType === 'png' diff --git a/excalidraw/src/index.js b/excalidraw/src/index.js index 23f0e2416..2102ac4d8 100644 --- a/excalidraw/src/index.js +++ b/excalidraw/src/index.js @@ -15,7 +15,7 @@ import { create } from './browser-instance.js' micro.serve(async (req, res) => { // TODO: add a /_status route (return excalidraw version) // TODO: read the diagram source as plain text - const diagramSource = await micro.text(req, { limit: '1mb', encoding: 'utf8' }) + const diagramSource = await micro.text(req, { limit: (process.env.KROKI_MAX_BODY_SIZE ?? '1mb'), encoding: 'utf8' }) if (diagramSource) { try { const svg = await worker.convert(new Task(diagramSource)) diff --git a/mermaid/src/index.js b/mermaid/src/index.js index 250e7124f..8e3ce734e 100644 --- a/mermaid/src/index.js +++ b/mermaid/src/index.js @@ -27,7 +27,7 @@ import { create } from './browser-instance.js' const url = new URL(req.url, 'http://localhost') // create a URL object. The base is not important here const outputType = url.pathname.match(/\/(png|svg)$/)?.[1] if (outputType) { - const diagramSource = await micro.text(req, { limit: '1mb', encoding: 'utf8' }) + const diagramSource = await micro.text(req, { limit: (process.env.KROKI_MAX_BODY_SIZE ?? '1mb'), encoding: 'utf8' }) if (diagramSource) { try { const isPng = outputType === 'png'