Problem/Motivation

Runlight does not currently work correctly when the Redirect module's “Enforce clean and canonical URLs” option is enabled.

Accessing Runlight returns:

{"error":"Not found","code":"not_found"}

Steps to reproduce

1. Enable the Redirect module.
2. Enable the “Enforce clean and canonical URLs” option, which sets:
route_normalizer_enabled: true
3. Configure Runlight to run inside the Drupal site.
4. Request /runlight/s.js.

Proposed resolution

Exclude Runlight paths from route normalization by setting the request attribute _disable_route_normalizer for /runlight and its subpaths.

Canonical URL normalization should remain enabled for the rest of the site.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

xmacinfo created an issue. See original summary.

xmacinfo’s picture

Issue summary: View changes
joncphillips’s picture

Thank you for reporting this @xmacinfo! I have a fix I'm testing now and will push a release out shortly.

xmacinfo’s picture

I am currently using this code in a custom module:

if ($path === '/runlight' || str_starts_with($path, '/runlight/')) {
  $event->getRequest()->attributes->set('_disable_route_normalizer', TRUE);
}

Not yet pushed to production.

joncphillips’s picture

Category: Feature request » Bug report
Status: Active » Fixed

Thanks for the clear report and the suggested fix, that was exactly it.

Runlight sends every path under /runlight to one route whose own path is /runlight. With "Enforce clean and canonical URLs" on, Redirect compared /runlight/s.js with that route's canonical path and redirected it to /runlight, which Runlight answers with "Not found". So it wasn't only the dashboard: the script, its API, and visit counting were all affected on sites with that option on.

The module's path processor now sets _disable_route_normalizer on requests under /runlight, so Redirect leaves those paths alone and keeps normalizing the rest of the site. The fix is in 0.4.1: https://www.drupal.org/project/runlight/releases/0.4.1

It does the same as the code in your custom module, so once you're on 0.4.1 you can remove that. (The module sets it only while Runlight runs inside the Drupal site; when it reports to another Runlight, /runlight is an ordinary path on your site and Redirect normalizes it like any other.)

Thanks again!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.