Funbit / ets2-telemetry-server

ETS2/ATS Telemetry Web Server + Mobile Dashboard
GNU General Public License v3.0
636 stars 209 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.

GregThB commented 1 month ago

Hello,

Please, can you reopen this issue ?

I am currently developing a PWA in VueJS, in order to display data on my phone under the same local network and I encounter CORS error.

I tried javacript "fetch()" API, "axios" node module, and also load url into an