Image uploads broken in Docker

My version of HedgeDoc is: 1.8.2

What I expected to happen:

I am running Hedgedoc in a docker container built using the docker-compose file in the documentation with an Nginx reverse proxy in front of it. I clicked the image upload button to insert an image from my local system, expecting it to be displayed in my document.

What actually happened:

When I selected the image to upload, my session was disconnected and when viewing the docker logs, observed the following NodeJS traceback:

2021-06-17T15:40:45.004Z error: uncaughtException: Invalid URL
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:363:5)
at onParseError (node:internal/url:536:9)
at new URL (node:internal/url:612:5)
at new URL (node:internal/url:609:22)
at Object.exports.uploadImage (/hedgedoc/lib/web/imageRouter/filesystem.js:28:19)
at /hedgedoc/lib/web/imageRouter/index.js:96:22
2021-06-17T15:40:45.004Z error: An uncaught exception has occured.
2021-06-17T15:40:45.004Z error: Invalid URL
2021-06-17T15:40:45.005Z error: Process will exit now.

I confirmed that the file had actually been uploaded to the container under /public/uploads/upload_24d0c142c250f4063c8802697f89c134.png, which could be manually inserted in the page via URL and would display as expected.

I already tried:

I tried setting the CMD_DOMAIN environment variable, but only succeeded in breaking the proxy and making the app unreachable.

Sounds like missing proxy headers or environment variables.
HedgeDoc can only work if you set CMD_DOMAIN correctly.
Have you read https://docs.hedgedoc.org/guides/reverse-proxy/ ?

Thanks, CMD_DOMAIN was the problem. Once I found the right setting for it, the uploads started working.