AEM SPA React - Dispatcher Setup | Community
Skip to main content
Level 3
October 20, 2020
Solved

AEM SPA React - Dispatcher Setup

  • October 20, 2020
  • 3 replies
  • 6048 views

We have tried to setup the dispatcher for the AEM SPA Journal Project.

In the Apache, we have done the rewrite to short the urls to hide the content hierarchy.

http://localhost/content/we-retail-journal/react/en/home.html to http://localhost/react/en/home.html

 

Only with the /content the react application is working and in the XHR there is only one call for model.json

 

And with the short url we are getting the two model.json calls that are 

 

What steps needed  in the AEM SPA dispatcher setup to hide the /content  hierarchy?

 

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 Nikhil-Kumar

@bipinch1  - Can you verify that, When you are hitting short URL then are you getting :children property in en.model.json ?

This happens when you page data is loaded from home.model.json instead of en.model.json.

So, In first case your data gets fetched from root e.model.json and whereas in second case it gets fetched from home.model.json(respecctive page). 

As per my understanding you :path property in preview mode of en.model.json should match with the request URI. So when you hit short path i.e without /content/project-name it looks for :path property in en.model.json  where it doesn't match and moves to individual page's model.json i.e home.model.json

3 replies

Shashi_Mulugu
Community Advisor
Community Advisor
October 20, 2020

@bipinch1 I think it is nothing to do with dispatcher. Please check your spa logic where it is firing two XHR requests.

BipinCh1Author
Level 3
October 21, 2020
@232100_Muluga It is out of box aem journal project provided by Adobe for SPA reference. I have not implemented any custom code.
Nikhil-Kumar
Community Advisor
Nikhil-KumarCommunity AdvisorAccepted solution
Community Advisor
October 21, 2020

@bipinch1  - Can you verify that, When you are hitting short URL then are you getting :children property in en.model.json ?

This happens when you page data is loaded from home.model.json instead of en.model.json.

So, In first case your data gets fetched from root e.model.json and whereas in second case it gets fetched from home.model.json(respecctive page). 

As per my understanding you :path property in preview mode of en.model.json should match with the request URI. So when you hit short path i.e without /content/project-name it looks for :path property in en.model.json  where it doesn't match and moves to individual page's model.json i.e home.model.json

Level 2
February 10, 2021

@bipinch1  I am also facing same issue. We are using SPA Editor project archetype 23. I have added rewrite rules on dispatcher for URL shortening. I am getting blank page. Whenever en.model.json is coming XHR, the page is coming blank. I tried to debug the issue and added vanity URL on publisher as /home.html, but same issue was there  on publisher too.                                                                                                                                               The issue is not with the dispatcher but in SPA whenever we are shortening the URL, the AEM-React integrated page is not getting rendered properly.

I tried to create non-SPA page with no-spa components in the same project, I am getting page properly with same dispatcher settings.

 

Please let me know, in case you got any solution 🙂

Thanks in Advance,

Nasrin

Level 2
February 10, 2021
So to summarize, I need to implement HierarchyNodeExporter and in sling model need to override getExportedPath(). In this method i have to replace "/content/projectname/en/home" to "/home". Correct me if I am going wrong.