Use url_for for advance fares API URL

Hardcoded path broke when deployed under a subpath such as
/paddington-eurostar/; generate the URL server-side with url_for instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-04-11 16:51:27 +01:00
parent 35097fda4f
commit b38951a6a5

View file

@ -264,8 +264,7 @@
</p>
<script>
var stationCrs = {{ station_crs | tojson }};
var travelDate = {{ travel_date | tojson }};
var advanceFaresUrl = {{ url_for('api_advance_fares', station_crs=station_crs, travel_date=travel_date) | tojson }};
var cachedAdvanceFares = {{ cached_advance_fares | tojson }};
function updatePrices() {
@ -315,7 +314,7 @@ function loadAdvanceFares() {
btn.disabled = true;
btn.textContent = 'Loading\u2026';
fetch('/api/advance_fares/' + stationCrs + '/' + travelDate)
fetch(advanceFaresUrl)
.then(function(r) { return r.json(); })
.then(function(data) {
if (data.error) {