AEM SPA Routing Issues with hash and query parameter | Community
Skip to main content
viveksachdeva
Community Advisor
Community Advisor
June 4, 2020
Solved

AEM SPA Routing Issues with hash and query parameter

  • June 4, 2020
  • 13 replies
  • 10698 views

Hey guys,

 

We are using AEM with React and having trouble with SPA Routing. We are facing an intermittent issue when the Link contains # or ?

Page data is available using .model.json on the page URI but sometimes when we have # and ?, model.json is added after full URL rather than just path and hence it fails.

And it happens when on dispatcher only when we dont have .html in the URL.

E.g:

Lets say a React Link points to /en/mypage?cid=campaign

I expect data call for this to be  /en/mypage.model.json but sometimes it is sent as /en/mypage?cid=campaign.model.json

 

This logic is abstracted in the node module and hence difficult to check. Anyone else faced similar issue?

 

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 dzmitryk7401781

We've prepared patch to fix it: https://github.com/adobe/aem-spa-page-model-manager/pull/54 

13 replies

Nikhil-Kumar
Community Advisor
Community Advisor
August 24, 2020

@viveksachdeva 

Try playing around with the dipatcher re-write rules if it helps.

We guys also implemented similar thing but didn't faced such issue.

viveksachdeva
Community Advisor
Community Advisor
August 25, 2020
The URL modification happens at client side before it reaches Dispatcher. For "#" in the URL, we were facing this issue consistently but query params, it was intermittent.
Level 2
March 5, 2021

We also have the same issue appearing, right after we started to rewrite URLs removing `.html` bit in a page path.

 

Looks to me that URL parsing code in the routing library contains a bug for the case of absent page extension and should be fixed.

viveksachdeva
Community Advisor
Community Advisor
March 21, 2021
Yeah. we had to change those links to normal links rather than React link..
dzmitryk7401781Accepted solution
Level 2
March 22, 2021
kautuk_sahni
Community Manager
Community Manager
March 23, 2021
@dzmitryk7401781, thank you for sharing the solution with community. Keep doing the great work. Looking forward to see you more in the AEM community.
Kautuk Sahni