Issue using suffix in the URL | Community
Skip to main content
Level 4
September 5, 2021
Solved

Issue using suffix in the URL

  • September 5, 2021
  • 3 replies
  • 2147 views

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 .

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 Asutosh_Jena_

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!

3 replies

arunpatidar
Community Advisor
Community Advisor
September 5, 2021

Hi,

can you try with something like below

 

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

 

Arun Patidar
Level 4
September 5, 2021

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]

 

Kishore_Kumar_
Level 9
September 5, 2021

Hi @_sumitsinghal ,

 

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

Level 4
September 5, 2021

Yes suffix should work with path bound also.

Asutosh_Jena_
Community Advisor
Asutosh_Jena_Community AdvisorAccepted solution
Community Advisor
September 6, 2021

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!

Level 4
September 7, 2021

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.