Websocket throws VM166:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0 error

Murthy Varanasi4 years ago

when connectig through websocket the, I had this erro. Any help pls

Anton Tananaev4 years ago

I would recommend you to provide more information.

Murthy Varanasi4 years ago

Ifollowe the wesocket api from the traccar official documentation. I had cors issue so i had to use "window.location.protocol +'//'+window.location.hostname" in theurl then this erro popped. If i am using the host http://xx.xx.xx.xx:8082 it is thrwing cors eerro
and being a beginner i am not sure where to add the "Access-Control-Allow-Origin: *" . I am looking for solution through this

I have my own webpage whic is pulling data from traccar using api and i can use it as per requirement. But i have to either create cron jobs ,or ajax to get live updates. SO i am looking for a way through it