Make requests to backend 404 pages not redirect.

Created on 19 April 2024, about 2 months ago
Updated 23 April 2024, about 2 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.

Production build 0.69.0 2024