ets2-telemetry-server icon indicating copy to clipboard operation
ets2-telemetry-server copied to clipboard

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

Open LunaFolf opened this issue 7 years ago • 2 comments

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

LunaFolf avatar Dec 18 '18 11:12 LunaFolf

I agree, this will be good

loulou123546 avatar Mar 18 '19 20:03 loulou123546

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.

dakar2008 avatar Feb 22 '20 16:02 dakar2008