Skip to content

Commit

Permalink
Change max body size using envvars when rendering diagramas (#1761)
Browse files Browse the repository at this point in the history
  • Loading branch information
eryalito authored Jul 22, 2024
1 parent 04d7d2e commit 21c486c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion diagrams.net/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion excalidraw/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion mermaid/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 21c486c

Please sign in to comment.