Canvas editor does not support language-prefixed URLs, breaks when accessed as /[langcode]/canvas/...
## Problem When a site uses URL-based language negotiation (e.g., a `/es/` prefix for Spanish), visiting a Canvas editor URL with a language prefix (e.g., `/es/canvas/1`) breaks the editor. The Canvas React application does not handle language-prefixed base paths and fails to initialize correctly. ## Why other editor UIs are not affected Standard Drupal content editing routes use the Drupal routing system, which handles language negotiation transparently. Canvas uses a React SPA that constructs its own internal paths and API requests based on the URL, making it sensitive to unexpected path prefixes that the SPA was not built to handle. ## Steps to reproduce 1. Enable the Language module and configure URL-based language detection (e.g., language prefix `/es/` for Spanish) 2. Log in as an editor 3. Navigate to `/es/canvas/[page-id]` **Expected**: Canvas editor loads (in default language — it edits structure, not translated content) **Actual**: Canvas editor breaks / fails to render ## Suggested fix Add a method to an event subscriber, CanvasRouteOptionsEventSubscriber, (or a new one) that detects when the current language differs from the default language and the request targets a `/canvas` path, then issues a 302 redirect to strip the language prefix. The subscriber must listen on `KernelEvents::REQUEST` with a priority high enough to run before routing: ```php public static function getSubscribedEvents(): array { $events[KernelEvents::REQUEST][] = ['redirectCanvasToDefaultLanguage', 100]; return $events; } public function redirectCanvasToDefaultLanguage(RequestEvent $event): void { $request = $event->getRequest(); $path = $request->getPathInfo(); $default_langcode = $this->languageManager->getDefaultLanguage()->getId(); $current_langcode = $this->languageManager->getCurrentLanguage()->getId(); if ($current_langcode !== $default_langcode) { $base_path = $request->getBasePath(); $canvas_path = preg_replace('#^/' . preg_quote($current_langcode, '#') . '/#', '/', $path); $event->setResponse(new RedirectResponse($base_path . $canvas_path, 302)); } } ``` ## Possible follow-ups Canvas editor should ideally support language-prefixed URLs natively rather than requiring a redirect. The redirect is a short-term fix; the long-term solution would make Canvas properly handle language-negotiated base paths in the React application.
issue