Adobe-Consulting-Services / acs-aem-commons

http://adobe-consulting-services.github.io/acs-aem-commons/
Apache License 2.0
455 stars 603 forks source link

Redirect Manager - AEM SPA not working #3104

Closed anshul-goyal-1 closed 1 year ago

anshul-goyal-1 commented 1 year ago

Required Information

Expected Behavior

While setting up the redirect via the Redirect Manager,I need to add a redirect and after publish can redirect to the source page. We are using AEM SPA based implementation

Actual Behavior

When I add a redirect, the page goes blank.

Steps to Reproduce

  1. Install the ACS Commons on AEM cloud service
  2. Create a redirect from a source "/test/" to destination - "https://www.google.com"
  3. Publish the redirect
  4. Try to access the redirect via publisher (http://localhost:4503/test/)

I get the blank page rather than it navigates to the destination page

Links

Links to related assets, e.g. content packages containing test components

redirect.zip

YegorKozlov commented 1 year ago

Do you have Sling Mappings to resolve /test/ to a full path , e.g. /content/my-site/en/test ?

If not, use the full JCR path, e.g. instead of /test/ the source should be /content/my-site/en/test

anshul-goyal-1 commented 1 year ago

The use case is that there is no physical page in AEM with a full path that resolves to /test/, In the e-commerce application, we need to apply the rules to /test/ category which is coming from the commerce engine and then re-direct it to a place in AEM. So I can put a destination to a full path like /content/my-site/en/new-landing but the source will not be a page/location within AEM.

Redirect Manager config: /test/ - http://localhost:4503/new-test

Sling Mappings:

  1. For model.json sling:match- localhost.4503/(new-test)/(.*).model.json internal-redirect:/content/my-site/en/$1.model.json
  2. For actual HTML sling:match- localhost.4503/(new-test)(.*)$ internal-redirect:/content/my-site/en/$1.html

So the question is if I need to do the /etc/mapping then what's the use of the redirect manager?

YegorKozlov commented 1 year ago

by default the Redirect Filter listens to /content/* requests: image

change it to an empty string to listen from the root. image

(the value "/" won't work, it's a bug which I'm going to fix)

with these settings it worked to me:

image
curl -I  http://localhost:4503/test
HTTP/1.1 302 Found
Date: Wed, 17 May 2023 08:31:33 GMT
Location: https://www.google.com
Content-Length: 0
anshul-goyal-1 commented 1 year ago

Thanks for the prompt reply and are you planning to release the fix for "/" soon or is there a roadmap for the same.

YegorKozlov commented 1 year ago

Thanks for the prompt reply and are you planning to release the fix for "/" soon or is there a roadmap for the same.

I'll try to include the fix in the upcoming 6.0.9

anshul-goyal-1 commented 1 year ago

Thanks, I will keep an eye and update it. Thanks for the help

YegorKozlov commented 1 year ago

https://github.com/Adobe-Consulting-Services/acs-aem-commons/issues/3105