zadam / trilium

Build your personal knowledge base with Trilium Notes
GNU Affero General Public License v3.0
27.2k stars 1.9k forks source link

(Bug report) Can't change note type to any type with a mime type #2419

Closed Cygon closed 2 years ago

Cygon commented 2 years ago

Preflight Checklist

Trilium Version

0.48.7

What operating system are you using?

Other Linux

What is your setup?

Server access only

Operating System Version

Gentoo Linux stable

Expected Behavior

I expect to be able to change a node's type by opening its type dropdown and selecting any type.

Actual Behavior

When I attempt to change a node's type to any type that specified a mime type in its PUT request, I get the following error message:

trilium-node-change-type-error ("Error when calling PUT notes//type/mermaid/mime/text%2Fmermaid: error - Not Found")

Additional Information

I am running Trilium on NodeJS v14.17.6, served via an Apache 2.4.48 proxy using the recommended proxy setup:

ProxyPass         /trilium/  http://127.0.0.1:21618/
ProxyPassReverse  /trilium/  http://127.0.0.1:21618/

Redirect        301     /trilium /trilium/

<Location "/trilium/">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

        RewriteEngine On
        RewriteCond %{HTTP:Connection} Upgrade [NC]
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteRule (.*) ws://127.0.0.1:21618/$1 [P,L]
</Location>

This is equivalent to the recommended proxy setup but omits the http to https redirect (I'm running Trilium in my home network only).


The backend log shows the following (I switched once to the 'book' type, once to the 'render' type and finally attempted to switch to the 'mermaid diagram' type, which failed):

23:23:44.449 Slow 200 GET /api/backend-log with 486319 bytes took 14ms
23:23:52.762 200 GET /api/notes/7RTd2tsKZjgz with 426 bytes took 3ms
23:23:52.832 204 PUT /api/notes/7RTd2tsKZjgz/type/book/mime/ with 0 bytes took 5ms
23:23:54.767 200 GET /api/notes/7RTd2tsKZjgz with 424 bytes took 4ms
23:23:54.839 204 PUT /api/notes/7RTd2tsKZjgz/type/render/mime/ with 0 bytes took 6ms
23:23:56.497 200 GET /api/notes/7RTd2tsKZjgz with 426 bytes took 7ms
23:23:56.569 JS Error: Error when calling PUT notes/7RTd2tsKZjgz/type/mermaid/mime/text%2Fmermaid: error - Not Found
Stack: N@http://horizon.home/trilium/app-dist/desktop.js:2:98436
throwError@http://horizon.home/trilium/app-dist/desktop.js:2:83891
c@http://horizon.home/trilium/app-dist/desktop.js:2:80736
Cygon commented 2 years ago

This may have to do with the Apache proxy configuration after all.

If I open the container's port and perform the change on http://horizon.home:21618/ directly (no Apache proxying), it works.

Maybe the Apache configuration shown in the Trilium Wiki incorrectly proxies this special case. Almost seems as if the %2F should be un-URL-encoded but isn't. This Apache issue (not necessarily related) has given me a few things to experiment with: https://bz.apache.org/bugzilla/show_bug.cgi?id=34602

zadam commented 2 years ago

Hi, same issue is described here

I faintly remember this being discussed also elsewhere with more information but can't find it now. I think it was some buggy behavior of Apache, but it could be changed with some config IIRC. I'm not sure if it's the bugzilla item you linked or not.

zadam commented 2 years ago

To avoid these kind of issues, 0.49 will have type and MIME in the body instead of in URL.