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

404 and around #708

Closed
digitalinferno opened this issue Nov 19, 2024 · 4 comments
Closed

404 and around #708

digitalinferno opened this issue Nov 19, 2024 · 4 comments

Comments

@digitalinferno
Copy link

If I create a plugin that serves a page when I request site/fakepage, for example using onPageRendering with $twigTemplate = 'fakepage.twig', Pico still considers this as 404 content. On the user side, everything works fine, but is404Content() returns true (similarly, on404ContentLoaded(&$rawContent) is also triggered). Is there a way to work around this? For instance, if I want to log all the requests that result in a 404, calls to site/fakepage would also be logged as 404s, but they shouldn't be.

Another question about 404 behavior: If I create a 404.md page and point to mysite/404, Pico serves the 404 page, but with a 200 OK response, because the page actually exists. Is it an expected behavior? A better practice would be to only allow a _404.md file, which is not accessible directly but is used by Pico to serve a 404 message when there is a bad request. This approach, like before, avoids false positives when plugins check for is404Content().

This comment was marked as outdated.

@PhrozenByte
Copy link
Collaborator

If I create a plugin that serves a page when I request site/fakepage, for example using onPageRendering with $twigTemplate = 'fakepage.twig', Pico still considers this as 404 content. […] Is there a way to work around this?

I'm afraid there isn't. There were plans for Pico 4.0 to fix that (by adding "virtual pages"), but that never materialized. Since your plugin is taking control anyway, you don't really have to care about is404Content() yielding true; the only effect it has is that you have to change the HTTP status code back to 200 OK.

Another question about 404 behavior: If I create a 404.md page and point to mysite/404, Pico serves the 404 page, but with a 200 OK response, because the page actually exists. Is it an expected behavior?

No, 404.md files are considered hidden and should therefore follow the is404Content path. Please check again (because the code looks right to me) and if Pico truly responds with 200 OK (check that no plugin is changing the status code!) please open a separate issue. However, as a disclaimer, since Pico's development has stopped, it's unlikely that it will be fixed.

@digitalinferno
Copy link
Author

I'm afraid there isn't. There were plans for Pico 4.0 to fix that (by adding "virtual pages"), but that never materialized.

Ok, thanks.

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! 👍

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

No branches or pull requests

2 participants