Specific to Firefox — missing token ‘user-agent’ in CORS header ‘Access-Control-Allow-Headers’ from...












0















I'm trying to make a api call to googleMapsClient geocode and I'm getting a XHR error only when using firefox. It works fine in chrome but in firefox, I'm getting the following error



>     Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at
> https://maps.googleapis.com/maps/api/geocode/json?address=Kothaguda%2C%20Hyderabad%2C%20Telangana%2C%20India&key=AIzaSyB3eaJ_PQV1JPDiYAppYjlhTNQKBKmwn2U.
> (Reason: missing token ‘user-agent’ in CORS header
> ‘Access-Control-Allow-Headers’ from CORS preflight channel)


Not sure why this is specific to Firefox. I can see that the there is a 'user-agent' http header in the request. Any help on this is highly appreciated.










share|improve this question























  • Disable whatever Firefox extensions you have installed. Or remove the part of your frontend code that’s adding a custom User-Agent request header to the request.

    – sideshowbarker
    Nov 21 '18 at 16:51













  • I don't have any extensions installed on Firefox. Also, I'm not adding a custom User-Agent request header from the frontend code. Browser itself is adding User-Agent header.

    – gerites
    Nov 22 '18 at 7:37
















0















I'm trying to make a api call to googleMapsClient geocode and I'm getting a XHR error only when using firefox. It works fine in chrome but in firefox, I'm getting the following error



>     Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at
> https://maps.googleapis.com/maps/api/geocode/json?address=Kothaguda%2C%20Hyderabad%2C%20Telangana%2C%20India&key=AIzaSyB3eaJ_PQV1JPDiYAppYjlhTNQKBKmwn2U.
> (Reason: missing token ‘user-agent’ in CORS header
> ‘Access-Control-Allow-Headers’ from CORS preflight channel)


Not sure why this is specific to Firefox. I can see that the there is a 'user-agent' http header in the request. Any help on this is highly appreciated.










share|improve this question























  • Disable whatever Firefox extensions you have installed. Or remove the part of your frontend code that’s adding a custom User-Agent request header to the request.

    – sideshowbarker
    Nov 21 '18 at 16:51













  • I don't have any extensions installed on Firefox. Also, I'm not adding a custom User-Agent request header from the frontend code. Browser itself is adding User-Agent header.

    – gerites
    Nov 22 '18 at 7:37














0












0








0


0






I'm trying to make a api call to googleMapsClient geocode and I'm getting a XHR error only when using firefox. It works fine in chrome but in firefox, I'm getting the following error



>     Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at
> https://maps.googleapis.com/maps/api/geocode/json?address=Kothaguda%2C%20Hyderabad%2C%20Telangana%2C%20India&key=AIzaSyB3eaJ_PQV1JPDiYAppYjlhTNQKBKmwn2U.
> (Reason: missing token ‘user-agent’ in CORS header
> ‘Access-Control-Allow-Headers’ from CORS preflight channel)


Not sure why this is specific to Firefox. I can see that the there is a 'user-agent' http header in the request. Any help on this is highly appreciated.










share|improve this question














I'm trying to make a api call to googleMapsClient geocode and I'm getting a XHR error only when using firefox. It works fine in chrome but in firefox, I'm getting the following error



>     Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at
> https://maps.googleapis.com/maps/api/geocode/json?address=Kothaguda%2C%20Hyderabad%2C%20Telangana%2C%20India&key=AIzaSyB3eaJ_PQV1JPDiYAppYjlhTNQKBKmwn2U.
> (Reason: missing token ‘user-agent’ in CORS header
> ‘Access-Control-Allow-Headers’ from CORS preflight channel)


Not sure why this is specific to Firefox. I can see that the there is a 'user-agent' http header in the request. Any help on this is highly appreciated.







javascript google-maps firefox cors






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 13:31









geritesgerites

63




63













  • Disable whatever Firefox extensions you have installed. Or remove the part of your frontend code that’s adding a custom User-Agent request header to the request.

    – sideshowbarker
    Nov 21 '18 at 16:51













  • I don't have any extensions installed on Firefox. Also, I'm not adding a custom User-Agent request header from the frontend code. Browser itself is adding User-Agent header.

    – gerites
    Nov 22 '18 at 7:37



















  • Disable whatever Firefox extensions you have installed. Or remove the part of your frontend code that’s adding a custom User-Agent request header to the request.

    – sideshowbarker
    Nov 21 '18 at 16:51













  • I don't have any extensions installed on Firefox. Also, I'm not adding a custom User-Agent request header from the frontend code. Browser itself is adding User-Agent header.

    – gerites
    Nov 22 '18 at 7:37

















Disable whatever Firefox extensions you have installed. Or remove the part of your frontend code that’s adding a custom User-Agent request header to the request.

– sideshowbarker
Nov 21 '18 at 16:51







Disable whatever Firefox extensions you have installed. Or remove the part of your frontend code that’s adding a custom User-Agent request header to the request.

– sideshowbarker
Nov 21 '18 at 16:51















I don't have any extensions installed on Firefox. Also, I'm not adding a custom User-Agent request header from the frontend code. Browser itself is adding User-Agent header.

– gerites
Nov 22 '18 at 7:37





I don't have any extensions installed on Firefox. Also, I'm not adding a custom User-Agent request header from the frontend code. Browser itself is adding User-Agent header.

– gerites
Nov 22 '18 at 7:37












2 Answers
2






active

oldest

votes


















1














Are you using the @google/maps package? Please note that this package is supposed to be used with node.js only, not in the browser. This is also stated in the README:




Attention!
This library is designed for server-side Node.js applications. Attempting to use it client-side, in either the browser or any other environment like React Native, may in some cases work, but mostly will not. Please refrain from reporting issues with these environments when attempting to use them, since server-side Node.js applications is the only supported environment for this library. For other environments, try the Maps JavaScript API, which contains a comparable feauture set, and is explicitly intended for use with client-side JavaScript.




I suggest using the Google Maps JavaScript API.






share|improve this answer































    0














    Just got done dealing with this exact same issue. I was using the @google/maps library and the geocoding worked fine in Chrome (v71) but the preflight failed in Firefox (v64) with the same error as the original question.



    As suggested by Rob, I ended up moving to using the Google Maps JavaScript API to do the geocoding instead.



    Looking at the details of each request... it appears that @google/maps npm package uses a different URL than the Google Maps JavaScript API. As a matter of fact... the URL used by the JavaScript API returns a JSONP structure and avoids dealing with the whole CORS thing all together.



    It's still a mystery to me why using @google/maps to geocode an address worked fine in Chrome and not in Firefox. I assume Firefox has more strict CORS requirements when compared to Chrome.






    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%2f53413174%2fspecific-to-firefox-missing-token-user-agent-in-cors-header-access-control%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









      1














      Are you using the @google/maps package? Please note that this package is supposed to be used with node.js only, not in the browser. This is also stated in the README:




      Attention!
      This library is designed for server-side Node.js applications. Attempting to use it client-side, in either the browser or any other environment like React Native, may in some cases work, but mostly will not. Please refrain from reporting issues with these environments when attempting to use them, since server-side Node.js applications is the only supported environment for this library. For other environments, try the Maps JavaScript API, which contains a comparable feauture set, and is explicitly intended for use with client-side JavaScript.




      I suggest using the Google Maps JavaScript API.






      share|improve this answer




























        1














        Are you using the @google/maps package? Please note that this package is supposed to be used with node.js only, not in the browser. This is also stated in the README:




        Attention!
        This library is designed for server-side Node.js applications. Attempting to use it client-side, in either the browser or any other environment like React Native, may in some cases work, but mostly will not. Please refrain from reporting issues with these environments when attempting to use them, since server-side Node.js applications is the only supported environment for this library. For other environments, try the Maps JavaScript API, which contains a comparable feauture set, and is explicitly intended for use with client-side JavaScript.




        I suggest using the Google Maps JavaScript API.






        share|improve this answer


























          1












          1








          1







          Are you using the @google/maps package? Please note that this package is supposed to be used with node.js only, not in the browser. This is also stated in the README:




          Attention!
          This library is designed for server-side Node.js applications. Attempting to use it client-side, in either the browser or any other environment like React Native, may in some cases work, but mostly will not. Please refrain from reporting issues with these environments when attempting to use them, since server-side Node.js applications is the only supported environment for this library. For other environments, try the Maps JavaScript API, which contains a comparable feauture set, and is explicitly intended for use with client-side JavaScript.




          I suggest using the Google Maps JavaScript API.






          share|improve this answer













          Are you using the @google/maps package? Please note that this package is supposed to be used with node.js only, not in the browser. This is also stated in the README:




          Attention!
          This library is designed for server-side Node.js applications. Attempting to use it client-side, in either the browser or any other environment like React Native, may in some cases work, but mostly will not. Please refrain from reporting issues with these environments when attempting to use them, since server-side Node.js applications is the only supported environment for this library. For other environments, try the Maps JavaScript API, which contains a comparable feauture set, and is explicitly intended for use with client-side JavaScript.




          I suggest using the Google Maps JavaScript API.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 10 at 9:21









          RobRob

          33618




          33618

























              0














              Just got done dealing with this exact same issue. I was using the @google/maps library and the geocoding worked fine in Chrome (v71) but the preflight failed in Firefox (v64) with the same error as the original question.



              As suggested by Rob, I ended up moving to using the Google Maps JavaScript API to do the geocoding instead.



              Looking at the details of each request... it appears that @google/maps npm package uses a different URL than the Google Maps JavaScript API. As a matter of fact... the URL used by the JavaScript API returns a JSONP structure and avoids dealing with the whole CORS thing all together.



              It's still a mystery to me why using @google/maps to geocode an address worked fine in Chrome and not in Firefox. I assume Firefox has more strict CORS requirements when compared to Chrome.






              share|improve this answer




























                0














                Just got done dealing with this exact same issue. I was using the @google/maps library and the geocoding worked fine in Chrome (v71) but the preflight failed in Firefox (v64) with the same error as the original question.



                As suggested by Rob, I ended up moving to using the Google Maps JavaScript API to do the geocoding instead.



                Looking at the details of each request... it appears that @google/maps npm package uses a different URL than the Google Maps JavaScript API. As a matter of fact... the URL used by the JavaScript API returns a JSONP structure and avoids dealing with the whole CORS thing all together.



                It's still a mystery to me why using @google/maps to geocode an address worked fine in Chrome and not in Firefox. I assume Firefox has more strict CORS requirements when compared to Chrome.






                share|improve this answer


























                  0












                  0








                  0







                  Just got done dealing with this exact same issue. I was using the @google/maps library and the geocoding worked fine in Chrome (v71) but the preflight failed in Firefox (v64) with the same error as the original question.



                  As suggested by Rob, I ended up moving to using the Google Maps JavaScript API to do the geocoding instead.



                  Looking at the details of each request... it appears that @google/maps npm package uses a different URL than the Google Maps JavaScript API. As a matter of fact... the URL used by the JavaScript API returns a JSONP structure and avoids dealing with the whole CORS thing all together.



                  It's still a mystery to me why using @google/maps to geocode an address worked fine in Chrome and not in Firefox. I assume Firefox has more strict CORS requirements when compared to Chrome.






                  share|improve this answer













                  Just got done dealing with this exact same issue. I was using the @google/maps library and the geocoding worked fine in Chrome (v71) but the preflight failed in Firefox (v64) with the same error as the original question.



                  As suggested by Rob, I ended up moving to using the Google Maps JavaScript API to do the geocoding instead.



                  Looking at the details of each request... it appears that @google/maps npm package uses a different URL than the Google Maps JavaScript API. As a matter of fact... the URL used by the JavaScript API returns a JSONP structure and avoids dealing with the whole CORS thing all together.



                  It's still a mystery to me why using @google/maps to geocode an address worked fine in Chrome and not in Firefox. I assume Firefox has more strict CORS requirements when compared to Chrome.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 27 at 6:19









                  MauriceMaurice

                  690615




                  690615






























                      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%2f53413174%2fspecific-to-firefox-missing-token-user-agent-in-cors-header-access-control%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

                      Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

                      ts Property 'filter' does not exist on type '{}'

                      Notepad++ export/extract a list of installed plugins