TFNS / CTFNote

CTFNote is a collaborative tool aiming to help CTF teams to organise their work.
GNU General Public License v3.0
519 stars 61 forks source link

Upload Image on hedgedoc pad doesn't work #18

Closed ghost closed 2 years ago

ghost commented 3 years ago

Trying to upload an image on a hedgedoc pad fails.

2021-02-23_14-05-21

Logs from the container:

codimd_1  | (node:51) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_URL]: Invalid URL: /pad/uploads/
codimd_1  |     at onParseError (internal/url.js:257:9)
codimd_1  |     at new URL (internal/url.js:333:5)
codimd_1  |     at new URL (internal/url.js:330:22)
codimd_1  |     at Object.exports.uploadImage (/hedgedoc/lib/web/imageRouter/filesystem.js:28:19)
codimd_1  |     at /hedgedoc/lib/web/imageRouter/index.js:63:22
codimd_1  | (node:51) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
codimd_1  | (node:51) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
codimd_1  | 2021-02-23T15:04:19.493Z info:      172.20.0.5 - - [23/Feb/2021:15:04:19 +0000] "POST /uploadimage HTTP/1.1" - - "http://127.0.0.1/pad/0r7z3QpWRf2groqjPIphGA" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"

Reverting to the codimd image is a temporary fix, but any ideas on how to actually fix it?

SakiiR commented 3 years ago

Should not be closed

I will look into it and get back to you guys :)

I think it's an issue with the passthru rule on the reverse proxy

SakiiR commented 3 years ago

According to this comment: https://github.com/hedgedoc/hedgedoc/issues/67#issuecomment-492123028

You have to set the right environment variables.

In my case, locally, I setted up the following env variables to make the filesystem upload mode to work:

    environment:
      CMD_DB_URL: postgres://ctfnote:ctfnote@db:5432/ctfnote
      CMD_URL_PATH: pad
      CMD_IMAGE_UPLOAD_TYPE: filesystem
      CMD_DOMAIN: 127.0.0.1 # This is the env var you want to set on your production server

This env var is affecting the link of the image when rendering markdown. But it affects other features as well :( I tried to tweak a bit to make the image link generic like //pad/images/test.png but it broke the "static assets" loading of the page.

XeR commented 2 years ago

Fixed in 90fbd9364af6ec947f7ebf566f393ff63f73557c You need to set tthe environment variables in .env