[AEM SPA | React] 2 calls for model.json ; page content is loading twice | Community
Skip to main content
Level 2
September 15, 2021
Solved

[AEM SPA | React] 2 calls for model.json ; page content is loading twice

  • September 15, 2021
  • 1 reply
  • 2745 views

I am facing issue in AEM SPA. This issue is on home page, there are 2 calls like below 

 

This issue occurs on publisher, whereas on dispatcher the page comes blank. Can someone please help to resolve this issue. 

Note :

1. Rest other pages are loading fine. 

2. On dispatcher I have URL shortening rules and on publisher I am resource resolver config. 

3. While testing I observe, that If I add some some character (dot or anything) on customheaderlibs.html, page work fine on both publisher & dispatcher.  

4. I have overridden the HierarchyPageImpl to handle the URL shortening to give short path for all children element. 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Asutosh_Jena_


#Trim off the .html from URI
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^/(.*).html$ /$1 [R=301,L,QSA]

 

# Shorten the Tenant Path without extension
RewriteRule ^/content/${CONTENT_FOLDER_NAME}/en/([^.]*)$ /$1 [R=301,L]

 

# Add html to the URI before sending to publisher.
RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/bin
RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{REQUEST_URI} !^/home
RewriteCond %{REQUEST_URI} !^/libs
RewriteCond %{REQUEST_URI} !^/saml_login
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteCond %{REQUEST_URI} !^/system
RewriteCond %{REQUEST_URI} !^/tmp
RewriteCond %{REQUEST_URI} !^/var
RewriteCond %{REQUEST_URI} !(.json|.jpe?g|.png|.svg|.JPG|.mp4|.mov)$
RewriteRule ^(/.*)$ $1.html [L,PT]

 

 

May I know on publisher, instead of resource resolver can I use anything else ? I tried etc mapping but dint work for me. may be something wrong which I did there. can you please share any sample if any. 


Please check the etc/maps configuration here:

https://aemsimplifiedbynikhil.wordpress.com/2020/08/26/shortening-of-url-using-etc-map/

 

Thanks!

1 reply

Asutosh_Jena_
Community Advisor
Community Advisor
September 15, 2021

Hi @gunjan_13 

 

It should not make the 2nd call. Looks like something wrong with the URL shortening with the resource resolver map configuration. Can you please share the rules that you applied for URL shortening?

 

Thanks!

Gunjan_13Author
Level 2
September 15, 2021

Hi @asutosh_jena_ 

thanks for looking into. 

 

I am using resource resolver factory config at publisher. 

 

"resource.resolver.mapping": [

"/:/","/content/sample-project/en/:/","/content/sample-project/my/:/"


]

* failing at publisher already * 

and then rewriting at dispatcher. 

Gunjan_13Author
Level 2
September 15, 2021


#Trim off the .html from URI
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^/(.*).html$ /$1 [R=301,L,QSA]

 

# Shorten the Tenant Path without extension
RewriteRule ^/content/${CONTENT_FOLDER_NAME}/en/([^.]*)$ /$1 [R=301,L]

 

# Add html to the URI before sending to publisher.
RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/bin
RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{REQUEST_URI} !^/home
RewriteCond %{REQUEST_URI} !^/libs
RewriteCond %{REQUEST_URI} !^/saml_login
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteCond %{REQUEST_URI} !^/system
RewriteCond %{REQUEST_URI} !^/tmp
RewriteCond %{REQUEST_URI} !^/var
RewriteCond %{REQUEST_URI} !(.json|.jpe?g|.png|.svg|.JPG|.mp4|.mov)$
RewriteRule ^(/.*)$ $1.html [L,PT]

 

 

May I know on publisher, instead of resource resolver can I use anything else ? I tried etc mapping but dint work for me. may be something wrong which I did there. can you please share any sample if any.