Expand my Community achievements bar.

Re: AEM Cloud Service | Getting geo location header in publish

Avatar

Employee Advisor

Every request reaching the AEM dispatchers via the CDN (which is default) should contain these additional HTTP headers provided by the CDN.

The situation can be different if you want to handle these headers in the AEM publish instance, because this requires that the dispatcher forwards these headers. Depending on your configuration this might or might not be the case (although it's default in the dispatcher config sample for some years and there's hardly a need to change that default).

4 Replies

Avatar

Level 2

Now we are getting the headers x-aem-client-country and x-aem-client-continent in publish dispatcher. How can we pass these headers to Client Side so that Front end can read these headers and act on it, please let me know

@Jörg_Hoh , @Asutosh_Jena_ 

Avatar

Employee Advisor

The flow is like this:

* the client (browser) requests a page from your site.

* this request is received by the CDN, and the CDN adds these headers to the request.

* the response for this request is either provided by the CDN, by the dispatcher or AEM. As these geo headers are just attached to the request, they are not part of the response.

 

If you need this information in the client, you need to add it explicitly to the response, either as HTTP header or as part of the payload.  Be aware of caching!

 

But the real question is: Why do you need this information on the client/browser? What do you want to achieve with it?

 

 

Avatar

Level 2

My component has to render different information based on user country.

 

If we read the header from server side, then it will be cached and hence to avoid caching I am trying to read the header from Client side and display the component dynamically from FE.

 

Please let me know if there is a way to achieve this. Many thanks. !

 

 

Avatar

Employee Advisor

I would use a dedicated service which is returning the actual location of the caller as part of the payload. I would not try to piggy-back this information somehow.

 

(And yes, it could be a servlet hosted on AEM, which is returning this information.)