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.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3589122-bat_fullcalendar_endpoint_urls_via_settings-11.1.x-dev.patch | 3.83 KB | carlitus |
| bat_fullcalendar_endpoint_urls_via_settings.patch | 3.3 KB | carlitus |
Comments
Comment #2
carlitus commentedComment #3
afagioliThanks 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
Comment #4
afagioliComment #5
carlitus commentedOk, new patch for 11.1.x-dev