A
A
albertalexandrov2019-05-23 21:44:14
JavaScript
albertalexandrov, 2019-05-23 21:44:14

XMLHttpRequest and VK openapi?

Hello.
Please tell me how to overcome the error when trying to use openapi VKontakte.

Access to XMLHttpRequest at ' https://login.vk.com/?act=openapi&oauth=1&aid=6995... ' from origin 'null' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values ​​' http://localhost, *', but only one is allowed.

Code to run (I just open the html page):
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://vk.com/js/api/openapi.js?160" type="text/javascript"></script>
</head>
<body>
    <script type="text/javascript">

        window.onload = (function() {
            VK.init({
                apiId: 6995083
            });

            function authInfo(response) {
                console.log(response);
            }
            
            VK.Auth.getLoginStatus(authInfo);
        })
    </script>
</body>
</html>

Application settings:
5ce6e9650f3c4124754868.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
svetlov97, 2019-05-23
@svetlov97

Another. No localhost address !!! It does not exist in nature! localhost or 127.0.0.1 points to the same computer from which it is called!!! VK your ip is unknown!!!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question