CORS Issue with MTA Bus Time API on Web App

10 views
Skip to first unread message

Manish Sharma

unread,
9:16 AM (7 hours ago) 9:16 AM
to mtadeveloperresources
Hello,

I am developing a web application that uses the MTA Bus Time API to fetch real-time vehicle data. While the API works perfectly in a Dart script (dart run), I am encountering a CORS issue when running the app in the browser.

Here are the details of the error:API Endpoint: https://bustime.mta.info/api/siri/vehicle-monitoring.json
Error Message:

HTTP Status Code: 302 (Found)

It seems the Access-Control-Allow-Origin header in the API response is set to https://bustime-beta.mta.info, which does not match my app's origin (http://localhost:16132). This is causing the browser to block the request.

Questions:Is there a way to configure the API to allow requests from my app's origin during development?
Are there any recommended workarounds for handling this issue in a web app?

Thank you for your assistance!
Reply all
Reply to author
Forward
0 new messages