Path aliases for translated pages show as "Error @page URL to Cache is a 404."

Created on 12 October 2023, about 1 year ago
Updated 15 October 2023, about 1 year ago

Problem/Motivation

I'm setting up a PWA using this module in a Drupal 9.5.11 site. The site has English and French pages. English is the default language and has no prefix. The French pages are detected with a URL prefix (/fr).

When I add the French paths in the "URLs to cache on install" section of the service worker, I get the error 'Error "@page" URL to Cache is a 404.'

Steps to reproduce

  1. Create a Drupal 9.5.11 site.
  2. Have at least two languages in place.
  3. Enable path aliases.
  4. Create a piece of content in one language and a translation in another language.
  5. Be sure to have different URL aliases for the different languages. /test and /fr/examen
  6. Add the PWA module and the service worker modules.
  7. Add the URL aliases (e.g. /test and /fr/examen) to the URLs to cache on install section and click save.
  8. You should see an error for the translated page.

Proposed resolution

Figure out why the $url->isRouted() on line 95 of the ServiceWorkerConfigurationForm is returning FALSE or check URL aliases for a language prefix and a path alias. Line 95 in the 2.1.0-beta: if (isset($url) && !$url->isRouted()) {

Currently, I've changed line 95 of the ServiceWorkerConfigurationForm to be:
if (isset($url) && !$url->toString()) {
This allows the French pages to be crawled.

Remaining tasks

Figure out a solution.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇨🇦Canada kdborg@gmail.com

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

Comments & Activities

Production build 0.71.5 2024