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

[Question] Is there a way to customize the 404 logic? #300

Closed
BrunoQuaresma opened this issue Aug 26, 2021 · 7 comments
Closed

[Question] Is there a way to customize the 404 logic? #300

BrunoQuaresma opened this issue Aug 26, 2021 · 7 comments
Labels
question Further information is requested

Comments

@BrunoQuaresma
Copy link

I have an app built using NextJS, and usually, the 404 page of NextJS returns the 200 status code because it is a static page. So, I would like to check the page using its body, looking for the canonical meta tag. Is that possible?

@mre
Copy link
Member

mre commented Aug 26, 2021

Hey Bruno,
interesting idea. This is not possible right now. I am thinking about an elegant way to make it happen, but it would require a user to work on the raw HTML response and feed the result back into lychee.

Anyone knows of a tool which supports that?

One could think of a scripting language like lua or a way to run custom shell scripts, but I don't think it will be quite elegant. The best solution I can think of is to create a custom checker based on lychee-lib as a library. It would require quite some Rust work I guess.

@mre mre added the question Further information is requested label Aug 26, 2021
@BrunoQuaresma
Copy link
Author

Hey Matthias, thanks for the reply.

I think a good UX could be something like:

lychee https://coder.com/docs/coder/blablabla --body "meta[canonical='https://coder.com/404']"

The user can pass a body option containing a CSS selector or even a REGEX if that is easier. Unfortunately, I have 0 skills in Rust 😅

@mre
Copy link
Member

mre commented Aug 27, 2021

What if you checked multiple websites? Should the --body parameter be used for all of them?

@lebensterben
Copy link
Member

@BrunoQuaresma

See this article at 35% mark: https://pretagteam.com/question/how-to-remove-404-error-in-nextjs-or-react-js

Next.js is able to return custom 404 page with 404 return code.

@lebensterben
Copy link
Member

In all cases without exception, we should expect the server to comply to IETF RFC 7231.

Treating well-defined return code in non-standard way should not be considered.

@MichaIng
Copy link
Member

Since currently with default -X get (and -X head anyway) only a small fraction of the response is actually downloaded, any flag/option which requires to download the whole response slows down the scan notably, which should be clear.

However, I guess the recursion feature has some basic function/method for this, probably only applied to text/html 200 responses, since it obviously as well requires to parse the whole response.

An I remember (cannot find currently) another request which required the whole response, so probably functions/methods can be reasonably shared as a basis for further such features.

@mre
Copy link
Member

mre commented Sep 4, 2021

Closing this as there is a preferable solution provided by @lebensterben and for the reasons stated in the comments.
Your input was very welcome @BrunoQuaresma and thanks for using lychee. 😃

@mre mre closed this as completed Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants