Clientlib Javascript calls to Google geocoding and timezone work fine on author instance but not on publish instance ( but maps are fine)

fionas76543059 20-12-2019

Hi folks,

 

I am a total novice with AEM.

I had to write a component which had a JS Client library which made some calls to the Google map API and some calls to other Google services like geocoding and timezone. I finally thought I got everything working and it worked perfectly on the Author instance when I "Viewed as Published".  I have a valid Google Key.  This is the jquery  "map" call that works and the request/response shows up on the Network Pane of my Web Console.

$('.event-location', wrap).html('<a href="https://www.google.com/maps/place/'+map+'" target="_blank">'+ address +'</a>').show();

 This is the jquery call that doesn't even show up on the Network Pane of my Web Console. (It is as if AEM swallowed it.)

$.get("https://maps.googleapis.com/maps/api/geocode/json?key="+ $googleApiKey + "&address=" + address, function(geo_data, geo_status){

 The Author and Publish instances are on the AEM Cloud. I ssh'd into the Publish instance and was able to successfully "curl" the above maps.googleapis.com API call so it doesn't seem to be a firewall issue.

 

Any thoughts ?  I put the client library "with" its component in /apps and included the call to the Clientlib CSS at the start of the component HTL file and the call to the JS at the end. This seems to be the current recommended way but I didn't see any other components done that way in the legacy code so maybe I've missed something here.

 

I have read that "Publish" server is more "locked down" that the Author instance so maybe there is some URL blocking or whitelisting or something like that that I don't know anything about.

 

All suggestions gratefully received!

 

thanks

Fiona

 

Accepted Solutions (1)

Accepted Solutions (1)

Arun_Patidar
MVP
20-12-2019

Yes, you need to enable an embed source. This can be done by allowing CORS.

This can be enabled at dispatcher level.

Answers (0)