Funbit / ets2-telemetry-server

ETS2/ATS Telemetry Web Server + Mobile Dashboard
GNU General Public License v3.0
614 stars 206 forks source link

Cors Issue (No 'Access-Control-Allow-Origin') #125

Closed LunaFolf closed 1 year ago

LunaFolf commented 5 years ago

Hi, I've downloaded and set up the server with no issue and everything works great, however when I try to grab the JSON response from the API I receive a No 'Access-Control-Allow-Origin' error, I took a look at the code to see if I could manually tweak it (just adding a Access-Control-Allow-Origin: * header should probably be enough) but I got lost.

Regards, LH

loulou123546 commented 5 years ago

I agree, this will be good

dakar2008 commented 4 years ago

In Ets2TelemetryController.cs there is a HttpResponseMessage called Get()

just insert this line: response.Headers.Add("Access-Control-Allow-Origin", "*"); after response.Headers.CacheControl = new CacheControlHeaderValue { NoCache = true }; and rebuild the project and publish it to a folder.