Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When trying to GET an unexisting item, a 200-OK is returned even if the file doesn't exist #39

Open
ktecho opened this issue Feb 7, 2025 · 3 comments
Assignees

Comments

@ktecho
Copy link

ktecho commented Feb 7, 2025

To Reproduce
Trying to do this:

const url = `${serverUrl}/random_sha256`;
const response = await fetch(url, { method: 'HEAD' });

either with HEAD of GET will return 200-OK. I think the problem is that the server is returning a picture correctly:

Image

@quentintaranpino quentintaranpino self-assigned this Feb 8, 2025
@quentintaranpino
Copy link
Owner

Yes, I’m aware that it always returns 200. This is intentional because if I return 404 along with the "not found" image, many Nostr clients display an error on the screen instead of the fallback image. So far, I haven’t found another way to "force" this image in all scenarios.

I also know that in the case of a file, video, or other file types, this behavior is not ideal either. For version 0.7.0, a dynamically generated "not found" file will be returned for each accepted file type. I’m experimenting with it.

@ktecho
Copy link
Author

ktecho commented Feb 9, 2025

Yeah, maybe an option in Setup to choose the behaviour, because right now there isn't a way to know if a file is present in the server in a programatical way, right?

@Giszmo
Copy link

Giszmo commented Feb 9, 2025

It looks like an easy fix. Change a number here. This might not be desirable for all users but if it's helpful for you, @ktecho, ...

As for the project merging this: I think it should signal 404 or provide an endpoint that allows checking availability of files. As @ktecho implied, as a compromise it could return the 404-image with 200 status on GET but the 404 status on HEAD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants