allOrigins icon indicating copy to clipboard operation
allOrigins copied to clipboard

Invalid JSONP response - Error shows DOCTYPE HTML code

Open Sebbo94BY opened this issue 3 years ago • 1 comments

Since a few hours, I have the problem, that the below code snippet...

$.ajax({
	type: "GET",
	url: "https://api.allorigins.win/get?url=" + encodeURIComponent("https://www.teamspeak.com/versions/client.json"),
	dataType: "json",
        [...]
});

...fails with this error:

Uncaught SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at JSON.parse (<anonymous>)
    at Object.success ((index):1349:15)
    at c (jquery-3.6.0.min.js:2:28327)
    at Object.fireWith [as resolveWith] (jquery-3.6.0.min.js:2:29072)
    at l (jquery-3.6.0.min.js:2:79901)
    at XMLHttpRequest.<anonymous> (jquery-3.6.0.min.js:2:82355)

Is this maybe related to https://github.com/gnuns/allOrigins/issues/115?

The code worked fine and as expected for the past months.

Could you please check, what's wrong here on the API side? Or did anything change?

Sebbo94BY avatar Dec 23 '22 01:12 Sebbo94BY

I have the same problem in the last month, allorigins changed their Accept: header from something safe like, this is from IE 9,

    "Accept": "text/html, application/xhtml+xml, */*", 

to https://api.allorigins.win/raw?url=http://httpbin.org/get

    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",

and the application/xml triggers certain Java EE frameworks (Jackson for example) to deliver XML instead of JSON by default if its in the accept headerline.

bulk88 avatar Dec 28 '22 01:12 bulk88