Wp-graphql not work - Unexpected token '<'

Website URL

go-kart-niscemi.freesite.online

Error Message

{
  "errors": {
    "message": "Unexpected token '<', \"<html><bod\"... is not valid JSON",
    "stack": "SyntaxError: Unexpected token '<', \"<html><bod\"... is not valid JSON"
  }
}

in response:

<html>
    <body>
        <script type="text/javascript" src="/aes.js"></script>
        <script>
            function toNumbers(d) {
                var e = [];
                d.replace(/(..)/g, function(d) {
                    e.push(parseInt(d, 16))
                });
                return e
            }
            function toHex() {
                for (var d = [], d = 1 == arguments.length && arguments[0].constructor == Array ? arguments[0] : arguments, e = "", f = 0; f < d.length; f++)
                    e += (16 > d[f] ? "0" : "") + d[f].toString(16);
                return e.toLowerCase()
            }
            var a = toNumbers("f655ba9d09a112d4968c63579db590b4")
              , b = toNumbers("98344c2eee86c3994890592585b49f80")
              , c = toNumbers("2ebbceba13aed1749c5066e861be0a2c");
            document.cookie = "__test=" + toHex(slowAES.decrypt(c, 2, a, b)) + "; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/";
            location.href = "https://go-kart-niscemi.freesite.online/index.php?graphql&i=1";
        </script>
        <noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>
    </body>
</html>

Other Information

I’m experiencing an issue with the WP-GraphQL plugin on my WordPress site hosted on InfinityFree. The GraphQL endpoint is returning the error instead of the expected JSON response.
I’m currently testing the call from the plugin itself

After having solved, i’m planning to consume this GraphQL API from a frontend application hosted on Vercel. Are there any CORS or other configurations needed to allow cross-origin requests from a Vercel-hosted domain?

1 Like

1 Like

you need to add a few things to the Vercel


Maybe this topic will interest you too

7 Likes

Look at my github aiceskekraje/vercel.json at main · mkfdj/aiceskekraje · GitHub , you need to be rlly carefull about the .json structure. For me it didn’t fix really anything I got rid of that cookie thing and used a int value that was randomly generated in the frontend and then sent to the backend where it was stored (Vercel app). Hope this helps!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.