Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

AEM SPA Short link implementation

Avatar

Level 3

Hi, AEM SPA application doesn't load when we change the URL through redirect or link shorting. Example, changing link from localhost:4502/content/project/us/en/pagename.html to localhost:4502/us/en/pagename.html. Page doesn't throw error but it's just blank page.

 

I saw some other questions on this forum explaining to change HierarchyPage model method getExportedPath(). 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-spa-react-dispatcher-s...

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/short-urls-using-react-spa...

 

Based on Google Search I came across HierarchyPage class. 

https://github.com/adobe/aem-sample-we-retail-journal/blob/master/bundles/core/src/main/java/com/ado...  

 

I have changed the getExportedPath().

 

  
     
     public String getExportedPath() {
        System.out.println(currentPage.getPath());
            String pagePath = currentPage.getPath();
        if(pagePath.contains("/content/project")){
            String trimmedPagePath = pagePath.replace("/content/project","");
            return trimmedPagePath;
        }
        else{
            return currentPage.getPath();
        }
     }

 

 

but still redirect or page sortlink doesn't work. Is this the correct implementation? or can someone share their custom page model implementation for the spa redirect/linkShorting.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
2 Replies

Avatar

Correct answer by
Community Advisor

Please have a look to implement url shortening in aem react spa http://experience-aem.blogspot.com/2021/10/aem-cloud-service-url-shortening-of-react-spa.html

Avatar

Community Advisor

Hi @DPrakashRaj 

 

I tried above sample project mentioned in the article, but as soon we change the hierarchical structure depth to 0, in template page policy. It stops working.

@snowwhite92did you found any solution to get it working?