No CORS support for traffic API calls?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm trying to integrate traffic API using javascript and have problem, because response does not contain CORS headers, I'm calling traffic API like this:



fetch('https://traffic.api.here.com/traffic/6.3/incidents.json?bbox=38.74123075381228,-99.00329589843751;42.771211138625894,-94.010009765625&app_id=xx_appid&app_code=xx_appcode&c=US&lg=en&i18n=true&localtime=true&units=metric').then(x => console.log(x.json()));


If I call places API using following:



fetch('https://places.cit.api.here.com/places/v1/discover/search?at=52.5044,13.3909&q=restaurant&app_id=oyncTDRmj660ffCKFjBD&app_code=1b5UNr1Z1vHiseGGj9zZoA&pretty&callback=myCallbackFunction&Accept-Language=de').then(x => console.log(x))


it returns all headers just fine:



HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://localhost:63342
Access-Control-Expose-Headers: X-Test, X-Map-Viewport, X-Mobility-Mode, X-
Accept-Encoding, X-Date, Authorization, Accept, Date, Accept-Encoding, User-Agent, Geolocation, Origin, Content-Type, DNT, Cache-Control, Last-Modified, Expires, Pragma, X-NLP-TID


Any ideas if I'm doing something wrong or there's workaround (not counting jsonp)?










share|improve this question






























    0















    I'm trying to integrate traffic API using javascript and have problem, because response does not contain CORS headers, I'm calling traffic API like this:



    fetch('https://traffic.api.here.com/traffic/6.3/incidents.json?bbox=38.74123075381228,-99.00329589843751;42.771211138625894,-94.010009765625&app_id=xx_appid&app_code=xx_appcode&c=US&lg=en&i18n=true&localtime=true&units=metric').then(x => console.log(x.json()));


    If I call places API using following:



    fetch('https://places.cit.api.here.com/places/v1/discover/search?at=52.5044,13.3909&q=restaurant&app_id=oyncTDRmj660ffCKFjBD&app_code=1b5UNr1Z1vHiseGGj9zZoA&pretty&callback=myCallbackFunction&Accept-Language=de').then(x => console.log(x))


    it returns all headers just fine:



    HTTP/1.1 200 OK
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: http://localhost:63342
    Access-Control-Expose-Headers: X-Test, X-Map-Viewport, X-Mobility-Mode, X-
    Accept-Encoding, X-Date, Authorization, Accept, Date, Accept-Encoding, User-Agent, Geolocation, Origin, Content-Type, DNT, Cache-Control, Last-Modified, Expires, Pragma, X-NLP-TID


    Any ideas if I'm doing something wrong or there's workaround (not counting jsonp)?










    share|improve this question


























      0












      0








      0








      I'm trying to integrate traffic API using javascript and have problem, because response does not contain CORS headers, I'm calling traffic API like this:



      fetch('https://traffic.api.here.com/traffic/6.3/incidents.json?bbox=38.74123075381228,-99.00329589843751;42.771211138625894,-94.010009765625&app_id=xx_appid&app_code=xx_appcode&c=US&lg=en&i18n=true&localtime=true&units=metric').then(x => console.log(x.json()));


      If I call places API using following:



      fetch('https://places.cit.api.here.com/places/v1/discover/search?at=52.5044,13.3909&q=restaurant&app_id=oyncTDRmj660ffCKFjBD&app_code=1b5UNr1Z1vHiseGGj9zZoA&pretty&callback=myCallbackFunction&Accept-Language=de').then(x => console.log(x))


      it returns all headers just fine:



      HTTP/1.1 200 OK
      Access-Control-Allow-Credentials: true
      Access-Control-Allow-Origin: http://localhost:63342
      Access-Control-Expose-Headers: X-Test, X-Map-Viewport, X-Mobility-Mode, X-
      Accept-Encoding, X-Date, Authorization, Accept, Date, Accept-Encoding, User-Agent, Geolocation, Origin, Content-Type, DNT, Cache-Control, Last-Modified, Expires, Pragma, X-NLP-TID


      Any ideas if I'm doing something wrong or there's workaround (not counting jsonp)?










      share|improve this question
















      I'm trying to integrate traffic API using javascript and have problem, because response does not contain CORS headers, I'm calling traffic API like this:



      fetch('https://traffic.api.here.com/traffic/6.3/incidents.json?bbox=38.74123075381228,-99.00329589843751;42.771211138625894,-94.010009765625&app_id=xx_appid&app_code=xx_appcode&c=US&lg=en&i18n=true&localtime=true&units=metric').then(x => console.log(x.json()));


      If I call places API using following:



      fetch('https://places.cit.api.here.com/places/v1/discover/search?at=52.5044,13.3909&q=restaurant&app_id=oyncTDRmj660ffCKFjBD&app_code=1b5UNr1Z1vHiseGGj9zZoA&pretty&callback=myCallbackFunction&Accept-Language=de').then(x => console.log(x))


      it returns all headers just fine:



      HTTP/1.1 200 OK
      Access-Control-Allow-Credentials: true
      Access-Control-Allow-Origin: http://localhost:63342
      Access-Control-Expose-Headers: X-Test, X-Map-Viewport, X-Mobility-Mode, X-
      Accept-Encoding, X-Date, Authorization, Accept, Date, Accept-Encoding, User-Agent, Geolocation, Origin, Content-Type, DNT, Cache-Control, Last-Modified, Expires, Pragma, X-NLP-TID


      Any ideas if I'm doing something wrong or there's workaround (not counting jsonp)?







      here-api






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 15:19







      Giedrius

















      asked Nov 16 '18 at 12:34









      GiedriusGiedrius

      5,42544077




      5,42544077






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Have you tried adding CORS authorization to headers in .htaccess file?



          1. Allow CORS authorization to headers by adding within .htaccess file:
            Header set Access-Control-Allow-Origin "*"

          2. Ensure your .htaccess file is located at root of your web-server.

          3. Restart your web-server.





          share|improve this answer

























          • I far as I understand, problem lies in here.com servers, where I do not have access to. Adding .htaccess file to my server (localhost) won't help I guess.

            – Giedrius
            Nov 16 '18 at 12:59











          • Have you tried adding it to localhost, and reproduce same error?

            – SamB
            Nov 17 '18 at 13:21


















          0














          I found that the CORS error was returned for us by the service when the app_id and app_code were either invalid or not specified. This was with the Javascript API rather than ReST but worth checking.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338017%2fno-cors-support-for-traffic-api-calls%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Have you tried adding CORS authorization to headers in .htaccess file?



            1. Allow CORS authorization to headers by adding within .htaccess file:
              Header set Access-Control-Allow-Origin "*"

            2. Ensure your .htaccess file is located at root of your web-server.

            3. Restart your web-server.





            share|improve this answer

























            • I far as I understand, problem lies in here.com servers, where I do not have access to. Adding .htaccess file to my server (localhost) won't help I guess.

              – Giedrius
              Nov 16 '18 at 12:59











            • Have you tried adding it to localhost, and reproduce same error?

              – SamB
              Nov 17 '18 at 13:21















            0














            Have you tried adding CORS authorization to headers in .htaccess file?



            1. Allow CORS authorization to headers by adding within .htaccess file:
              Header set Access-Control-Allow-Origin "*"

            2. Ensure your .htaccess file is located at root of your web-server.

            3. Restart your web-server.





            share|improve this answer

























            • I far as I understand, problem lies in here.com servers, where I do not have access to. Adding .htaccess file to my server (localhost) won't help I guess.

              – Giedrius
              Nov 16 '18 at 12:59











            • Have you tried adding it to localhost, and reproduce same error?

              – SamB
              Nov 17 '18 at 13:21













            0












            0








            0







            Have you tried adding CORS authorization to headers in .htaccess file?



            1. Allow CORS authorization to headers by adding within .htaccess file:
              Header set Access-Control-Allow-Origin "*"

            2. Ensure your .htaccess file is located at root of your web-server.

            3. Restart your web-server.





            share|improve this answer















            Have you tried adding CORS authorization to headers in .htaccess file?



            1. Allow CORS authorization to headers by adding within .htaccess file:
              Header set Access-Control-Allow-Origin "*"

            2. Ensure your .htaccess file is located at root of your web-server.

            3. Restart your web-server.






            share|improve this answer














            share|improve this answer



            share|improve this answer








            answered Nov 16 '18 at 12:45


























            community wiki





            SamB













            • I far as I understand, problem lies in here.com servers, where I do not have access to. Adding .htaccess file to my server (localhost) won't help I guess.

              – Giedrius
              Nov 16 '18 at 12:59











            • Have you tried adding it to localhost, and reproduce same error?

              – SamB
              Nov 17 '18 at 13:21

















            • I far as I understand, problem lies in here.com servers, where I do not have access to. Adding .htaccess file to my server (localhost) won't help I guess.

              – Giedrius
              Nov 16 '18 at 12:59











            • Have you tried adding it to localhost, and reproduce same error?

              – SamB
              Nov 17 '18 at 13:21
















            I far as I understand, problem lies in here.com servers, where I do not have access to. Adding .htaccess file to my server (localhost) won't help I guess.

            – Giedrius
            Nov 16 '18 at 12:59





            I far as I understand, problem lies in here.com servers, where I do not have access to. Adding .htaccess file to my server (localhost) won't help I guess.

            – Giedrius
            Nov 16 '18 at 12:59













            Have you tried adding it to localhost, and reproduce same error?

            – SamB
            Nov 17 '18 at 13:21





            Have you tried adding it to localhost, and reproduce same error?

            – SamB
            Nov 17 '18 at 13:21













            0














            I found that the CORS error was returned for us by the service when the app_id and app_code were either invalid or not specified. This was with the Javascript API rather than ReST but worth checking.






            share|improve this answer



























              0














              I found that the CORS error was returned for us by the service when the app_id and app_code were either invalid or not specified. This was with the Javascript API rather than ReST but worth checking.






              share|improve this answer

























                0












                0








                0







                I found that the CORS error was returned for us by the service when the app_id and app_code were either invalid or not specified. This was with the Javascript API rather than ReST but worth checking.






                share|improve this answer













                I found that the CORS error was returned for us by the service when the app_id and app_code were either invalid or not specified. This was with the Javascript API rather than ReST but worth checking.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 11 at 0:24









                Ross CoundonRoss Coundon

                5619




                5619



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338017%2fno-cors-support-for-traffic-api-calls%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    政党

                    天津地下鉄3号線