DVinyl icon indicating copy to clipboard operation
DVinyl copied to clipboard

[Bug]: QR codes not working perfectly

Open jws5406 opened this issue 3 months ago • 12 comments

Before reporting

  • [x] I am running the latest version of DVinyl.
  • [x] I searched the existing issues and did not find a duplicate.

What happened?

The QR codes option has a few issues.

  1. In the vinyl collection it generates a QR code but the url starts with "http" this should be "https" in ( I hope) most cases. I have set the environment variable to production since I am using https (behind a proxy server).
Image
  1. In the custom made collections the problem is a little different. It also creates a "http" url but also the qr code image is not a valid image.
Image
  1. In the custom collections the QR link can not be deleted. It display a "404" error.
Image

Furthermore I noticed only admins can generate a QR code. I normally never use the program as an admin. The admin account is only used to change the database setup. Under normal circumstances I usually work as an editor (in all programs) to avoid catastrophic unintended mistakes. So it would be great if regular users could also create an QR code.

Steps to reproduce

Make an QR code as descibed.

Expected behavior

No response

DVinyl version

3.1.3

How are you running DVinyl?

Docker (pre-built image)

Affected media type or plugin

No response

Browser and device

No response

Logs or screenshots


jws5406 avatar Aug 20 '26 08:08 jws5406

Hi,

Thanks for the report!

I will look at this asap

Siebe-Uy avatar Aug 20 '26 10:08 Siebe-Uy

Dug into this - opened a fix in #113.

Root cause

The share link / QR code URL is built with req.protocol (routes/adminRoutes.ts), which only reports https when:

  1. Express trust proxy is set (this app only does that when PROD=true, see app.ts), and
  2. the reverse proxy in front of the app actually sends an X-Forwarded-Proto: https header on every request.

If either of those isn't true, req.protocol silently falls back to http - even though the site is genuinely served over HTTPS. #113 makes the app trust PROD=true directly instead of depending on the forwarded header, so this can't happen anymore regardless of proxy config.

How to set up HTTPS correctly (for anyone hitting this)

In .env:

PROD=true

Note it must be the literal string true, not production or anything else - the app does a strict === 'true' check.

If you're behind a reverse proxy (nginx, Caddy, Traefik, etc.), make sure it forwards the original protocol, e.g. for nginx:

proxy_set_header X-Forwarded-Proto $scheme;

This is already called out in docs/getting-started.md, but easy to miss.

The other two symptoms in this issue

I could not reproduce the "QR code image is not a valid image" or the "404 on deleting a QR link" for custom (non-default) collections against current main. Set up a local test instance (in-memory MongoDB, fresh DB) and created a second custom collection alongside the default one specifically to check this - share link creation, QR code, and delete all worked normally on the custom collection.

My best guess is these were already fixed by earlier commits (fbe3e58 "stop serving the QR code of a share link that was switched off", 0fdc5c3 "report a delete that removed nothing") that landed after whatever version you were testing on. If you still see either of those two on latest main, could you post the exact repro steps and, if possible, the HTTP status code + response body from the browser's Network tab for the failing request? That'll make it much faster to track down if it's still there.

Siebe-Uy avatar Aug 20 '26 11:08 Siebe-Uy

Thank you!!

Kyonew avatar Aug 20 '26 11:08 Kyonew

The X-Forwarded-Proto: https fixed the first problem. So thanks for that one.

The other problem still exists though. I will try to reproduce it with an temporary collection. And YES the "whatever version you were testing on" is the latest version 3.1.3 as stated in the bug report above.

jws5406 avatar Aug 20 '26 14:08 jws5406

What is the 'other problem'? I'll take a look!

I hadn't noticed the note that “only user admins can generate links.” Personally, I think it’s too risky to let regular “editors” generate these links. There’s also a big difference between a collection admin and an instance-wide admin.. The latter can indeed be dangerous! you're 100% right to not use this account. The thing is, collection admins don’t have enough permissions to perform irreversible actions across the entire app.. I think it's up to them to create the links: they own their collection, so they're the ones who decide whether or not to share it 🤷‍♂️

Kyonew avatar Aug 20 '26 15:08 Kyonew

The other problem is point 2 & 3 Siebe-Uy could not reproduce. As far as I can tell it has something to do with the X-Forwarded-Proto as well. I could reproduce the error with the the QR image exactly one more time. After that is seems to be working fine. The strange thing is that remains: I have two collections with the broken QR image. Those can not be deleted, it results in the error as mentioned in point 3. I guess it has something to do with the fact that the server tries to delete the broken image? Guess I have revert to a backup to fix this.

The admin point is arguably valid. I had not realized the "instance admin" is different from the "collection admin". They both are listed as admin in the user list. I will change some users to "collection admin"

jws5406 avatar Aug 20 '26 15:08 jws5406

I'll look into it. Since I didn't write this feature, I'll need a little more time to debug it xD

Oh and normally, an admin at the instance level has a little badge! I hope that helps Image

Kyonew avatar Aug 20 '26 15:08 Kyonew

Found it! and it's a bug, nothing to do with the proxy this time. Share links get a random code, and every now and then that code happens to contain two letters that DVinyl mistakes for one of its sections. When that section is turned off in the collection you're browsing, the QR image and the delete button both land on a 404. That's exactly why it only hit some of your links and not others.

The same thing can happen to a collection you're trying to delete, which explains your two stuck ones

I'm fixing it for the next release. No need to revert to a backup, they'll delete just fine once it's in! Thanks again

Kyonew avatar Aug 20 '26 15:08 Kyonew

Thanks for pinpointing this so fast.

And I did notice the "instance" badge but did not link it to the difference in admin rights.

jws5406 avatar Aug 20 '26 16:08 jws5406

Found it! and it's a bug, nothing to do with the proxy this time. Share links get a random code, and every now and then that code happens to contain two letters that DVinyl mistakes for one of its sections. When that section is turned off in the collection you're browsing, the QR image and the delete button both land on a 404. That's exactly why it only hit some of your links and not others.

The same thing can happen to a collection you're trying to delete, which explains your two stuck ones

I'm fixing it for the next release. No need to revert to a backup, they'll delete just fine once it's in! Thanks again

Oh wow that is an insanely simple bug but hard to spot, great job fixing :)

Siebe-Uy avatar Aug 20 '26 17:08 Siebe-Uy

Hi! I just released version 3.1.4, and all three of these are fixed :D

Feel free to reopen the issue if you run into any problems!!

Kyonew avatar Aug 21 '26 13:08 Kyonew

I can confirm, all issues are resolved. Thanks, great work.

jws5406 avatar Aug 21 '26 13:08 jws5406