Using Dispatcher code in AEM SPA cloud shortening the URL | Community
Skip to main content
Level 6
May 24, 2023

Using Dispatcher code in AEM SPA cloud shortening the URL

  • May 24, 2023
  • 5 replies
  • 2987 views

I have written Dispatcher rewrite to shorten the URL. Urls are being shortened but the page is not rendering anything it is appearing blank.

Model JSON is loading fine on both Publish and Dispatcher content is exactly the same. Screenshot is attached below

 

On Publish env


On Dispatcher

 

What shall I do now? I am confused

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

5 replies

Umesh_Thakur
Community Advisor
Community Advisor
May 24, 2023

it seems you clientlibs are not loading, can you check is proxy enabled for the required clientlibs or not?

Ronnie09Author
Level 6
May 24, 2023

@umesh_thakur 

 

Clientlibs are loading that icon is coming because of HTTP request. I tried to open in new tab it has the data

rawvarun
Community Advisor
Community Advisor
May 24, 2023

Can you check https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-spa-react-dispatcher-setup/td-p/383861 for dispatcher setup with AEM SPA project.

Also, check AEM and dispatcher logs to see any error.

Ronnie09Author
Level 6
May 24, 2023

Hi @rawvarun 

 

Yes, I check that solution out. My model json and the path are the same as well as there are no errors on the Dispatcher log.

 

For frontend changes,  I followed https://experiencing150.rssing.com/chan-25971229/article453.html 

DPrakashRaj
Community Advisor
Community Advisor
May 25, 2023

I don’t see .html file extension fir the dispatcher url. Can you check with .html extension for dispatcher url as well or you have setup on dispatcher to work as extension less url?

Ronnie09Author
Level 6
May 25, 2023

@dprakashraj 

 

From dispatcher, I made extensionless URL

DPrakashRaj
Community Advisor
Community Advisor
May 25, 2023

So when you request page from dispatcher does the request going to aem publisher and if not then you might need to check the dispatcher rules for shortened url

Level 2
May 25, 2023

Is the request going as full path to publisher from dispatcher after you rewrite in dispatcher?. It seems publisher could not process shorten url. We can enable shorten url using JcrResourceResolverFactoryImpl. Please check the below article.

 

https://blogs.perficient.com/2021/01/11/unit-testing-jcr-resource-resolver-mappings/

 

Ronnie09Author
Level 6
May 25, 2023

@purnatummalapalli 

How can I verify that request is going to publish. Currently, I just have a dispatcher which is handling everything.

 

<IfModule mod_rewrite.c>
RewriteEngine on
 
    # rewrite for load root page
    RewriteCond %{HTTP_HOST} !^localhost    
    RewriteRule ^/?$ http://%{ENV:SAMPLE_HOST_PREFIX}%{HTTP_HOST}/us/en/home.html [R=301,L]
 
   
    # rewrite for redirect wrong links that beginning with '/content/sample'
    RewriteRule ^/content/sample/(.*) /$1 [E=SAMPLE_REDIRECT:1,NC]
 
    # rewrite for redirect wrong links that ending with extension '.html'
    RewriteCond %{HTTP_HOST} !^localhost    
    RewriteCond %{REQUEST_URI} !^/libs
    RewriteRule ^(.*)\.html$ $1 [E=SAMPLE_REDIRECT:1,N,NC]
 
    # rewrite for redirect wrong links that ending with '/'
    RewriteCond %{HTTP_HOST} !^localhost    
    RewriteRule ^(.*)/$ $1 [E=SAMPLE_REDIRECT:1,N]
 
    RewriteCond  %{ENV:SAMPLE_REDIRECT} "=1" [OR]
    #RewriteCond  %{ENV:SAMPLE_HOST_PREFIX} "=www." [OR]
    RewriteCond  %{ENV:SAMPLE_HTTPS} "=1"
    RewriteCond  %{REQUEST_URI} !^/dispatcher/invalidate.cache$
    RewriteRule ^(.*)$ http://%{ENV:SAMPLE_HOST_PREFIX}%{HTTP_HOST}$1 [R=301,L]
 
    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} !^/system
    RewriteCond %{REQUEST_URI} !^/tmp
    RewriteCond %{REQUEST_URI} !^/var
    RewriteCond %{REQUEST_URI} \.(jpe?g|png|svg|json|form)$
    RewriteRule ^/(.*)$ /content/sample/$1 [PT,L]
 
    RewriteCond %{REQUEST_URI} !^/content/ [NC]
    RewriteCond %{REQUEST_URI} !^/etc.clientlibs [NC]
    RewriteCond %{REQUEST_URI} !^/bin [NC]
    RewriteCond %{REQUEST_URI} !^/libs
    RewriteCond %{REQUEST_URI} !\.(.+)$
    #/ar-us
    RewriteRule ^/([^\?]*)(.*)$ /content/sample/$1.html$2 [PT,L]
</IfModule>
Level 3
September 5, 2023

we are also facing similar issue. Was there any solution for this?