Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Issue using suffix in the URL

Avatar

Level 4

Hi Team,

On publisher, requested url with suffix ( is dynamic which changes with environment so can't be made static ) is being blocked by dispatcher even after adding a rule to allow the request url.

Requested URLhttps://domain.com/bin/project/proxy.json/1.1/column/None/()/cms/dev/user

Rules tried : 

 

/1040 { /type "allow" /method '(GET|PUT)' /url "/bin/project/proxy.json*" }   

 

/1040 { /type "allow" /method '(GET|PUT)' /url "/bin/project/api-proxy.json*" /suffix "*" }

 

Any help will be highly appreciated .

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @_SumitSinghal 

 

As I can see it's a path based servlet so it will not work. You will need to convert it into Resource Types based.

 

As per SLING documentation:

"path-bound servlets can only be registered to a path and not a resource type (i.e. no suffix handling)"

 

Please see the link below:

https://sling.apache.org/documentation/the-sling-engine/servlets.html#example-registration-by-path-1

 

Hope this helps!

Thanks!

View solution in original post

6 Replies

Avatar

Community Advisor

Hi,

can you try with something like below

 

/type "allow"
/path "/bin/twitter/api-proxy"
/method '(get|put)'
/extension 'json'
/suffix '*'

 



Arun Patidar

Avatar

Level 4

Hi Arun,

 

Thanks for sharing. 

I tried the rule which you shared but it gives me 404 error after deployment.

I found the issue is not with the filter rule but when I add RewriteRule with a passthrough to allow the requested URL it works.

/1040 { /type "allow" /method '(GET|PUT)' /url "/bin/project/api-proxy.json*" }
RewriteRule ^/bin/project/api-proxy.json/(.*)$ /bin/project/api-proxy.json/$1 [NC,PT,L]

 

Avatar

Community Advisor

Hi @_SumitSinghal ,

 

Just trying to understand, whether suffix will work for path bound servlets ?

Avatar

Correct answer by
Community Advisor

Hi @_SumitSinghal 

 

As I can see it's a path based servlet so it will not work. You will need to convert it into Resource Types based.

 

As per SLING documentation:

"path-bound servlets can only be registered to a path and not a resource type (i.e. no suffix handling)"

 

Please see the link below:

https://sling.apache.org/documentation/the-sling-engine/servlets.html#example-registration-by-path-1

 

Hope this helps!

Thanks!

Avatar

Level 4

Hi @Asutosh_Jena_ 

Thank you !

But using resourceType will not work in my use case . I found the solution using "/bin"path with suffix and it works as expected.