Make requests to backend 404 pages not redirect.

Created on 19 April 2024, 12 months ago

Problem/Motivation

When a default 404 page is configured (in Configuration > Basic site settings), requests to unknown (non-CE-API) pages get redirected to the frontend.

We want to prevent that.

Steps to reproduce

  • Configure path in page.404 in system.site settings (a.k.a. "Default 404 (not found) page" in admin/config/system/site-information)
  • Visit BACKEND-URL/nonexistent-page
  • Be redirected to the frontend

Proposed resolution

... under discussion in the comments.

Remaining tasks

Decide on implementation.

Likely: take care of the "Default 403 (access denied) page" setting in an equivalent way.

User interface changes

Visiting BACKEND-URL/nonexistent-page will not (be redirected to and) display a neatly rendered page, anymore.

This is not usually a problem, because backend URLs aren't usually visited by people who should see neatly rendered pages.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @roderik
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    A solution I was tinkering with (diff, no MR yet) cancels the redirection. It then renders the 404 page in "whatever default backend view mode".

    I personally don't like this as a general addition to this module. Because "whatever default backend view mode" is not necessarily configured to be non-ugly. So the 404 page may come out ugly and even may disclose some information that looks strange.

    Example output for https://OUR-SITE'S-BACKEND-DOMAIN/nonexistent-page is attached to this issue as a screenshot, to show what I mean.

    Alternative solution, which we should probably impement, is: add an extra class that

    • extends Core's DefaultExceptionHtmlSubscriber (i.e. subscribes to onException)
    • that preempts CustomPageExceptionHtmlSubscriber (higher priority) - i.e. prevents CustomPageExceptionHtmlSubscriber from ever trying to render a frontend node
    • that does the same check as CustomPageExceptionHtmlSubscriber (do we have page.403 or page.404 configured?)
    • and in that case: renders /system/404 (a plain simple "Page not found" message) instead of the actual page.404 path.
  • 🇦🇹Austria fago Vienna

    @roderik

    Yes, that seems fine. We should not redirect any 4xx or 5xx errors and show them within Drupal.

    Thus, I think the fix is good. But I'd suggest we also test-coverage for that to fix the behavior:
    * 4xx / 5xx errors are shown within drupal
    * Access frontend route like node/123 redirects to frontend

    Not sure whether the seccond part is already covered.

  • Status changed to Postponed: needs info 4 months ago
  • 🇦🇹Austria fago Vienna

    I cannot reproduce the described behavior. If it really happens, it certainly qualifies as bug, thus fixing the category. Please provide steps to reprodocue, e.g. with gitpod test environments.

Production build 0.71.5 2024