Issue using suffix in the URL | Community
Skip to main content
Level 4
Sep 5, 2021 3:14 PM UTC
Solved

Issue using suffix in the URL

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 URL : https://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 .

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Asutosh_Jena_
Asutosh_Jena_Accepted solution
New Participant
Sep 6, 2021 4:42 AM UTC

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!

6 replies

Asutosh_Jena_
Asutosh_Jena_Accepted solution
New Participant
Sep 6, 2021 4:42 AM UTC

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!

Translate
Level 4
Sep 7, 2021 4:29 AM UTC

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. 

Translate
Kishore_Kumar_
Level 9
Sep 5, 2021 4:22 PM UTC

Hi @_sumitsinghal ,

 

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

Translate
Level 4
Sep 5, 2021 4:26 PM UTC

Yes suffix should work with path bound also.

Translate
arunpatidar
New Participant
Sep 5, 2021 3:40 PM UTC

Hi,

can you try with something like below

 

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

 

Translate
Arun Patidar
Level 4
Sep 5, 2021 4:24 PM UTC

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]

 

Translate