Currently bat_fullcalendar.js and bat_fullcalendar_scheduler.js build the calls to bat_api's REST endpoints (/bat_api/rest/calendar-units and /bat_api/rest/calendar-events) with hardcoded path
strings. This breaks on multilingual sites that use a path-prefix language negotiator: requests go out without the language prefix, Drupal issues a 301 redirect to the prefixed URL, and every
calendar refresh pays an extra round-trip (and CORS/cookie pitfalls in some setups).

There is also an undeclared coupling: the JS unconditionally calls bat_api endpoints, but bat_fullcalendar.info.yml does not list bat_api as a dependency.

This patch:

1. Adds bat_api as a declared dependency in bat_fullcalendar.info.yml, making the existing implicit coupling explicit.
2. In bat_fullcalendar_configure(), exposes the two endpoint URLs in drupalSettings.batCalendar[i] as unitsUrl and eventsUrl, computed via Url::fromRoute('rest.bat_api_units_resource.GET') /
rest.bat_api_events_resource.GET. This produces language-aware URLs that respect the active language prefix, aliases, and any future route changes in bat_api.
3. Updates bat_fullcalendar.js and bat_fullcalendar_scheduler.js to read those URLs from drupalSettings instead of hardcoding the paths.

No behavioural change on monolingual sites; on multilingual sites the redirect on each calendar load goes away.

Patch developed with the help of Claude while debugging a multilingual Drupal site that hit the redirect issue described above. Reviewed and tested manually on bat 11.1.0-rc9 before submission.

Comments

carlitus created an issue. See original summary.

carlitus’s picture

Assigned: carlitus » Unassigned
Status: Active » Needs review
afagioli’s picture

Thanks for the patch - the fix is excellent! 👍

Unfortunately it doesn't apply cleanly against the latest 11.1.x dev

Could you please re-roll your patch against the most updated 11.1.x branch

Thanks

afagioli’s picture

Version: 11.1.0-rc9 » 11.1.x-dev
carlitus’s picture

Ok, new patch for 11.1.x-dev

  • afagioli committed f8e12e20 on 11.1.x
    Issue #3589122: Make calendar endpoint URLs configurable via...

  • afagioli committed f8e12e20 on 11.0.x
    Issue #3589122: Make calendar endpoint URLs configurable via...