How to remove pathsuffix from being forwarded to target

Not applicable

Hi,

How do I remove proxy.pathsuffix or prevent it from being added to the target url?

As an example, my proxy end point:

virtual host: http://my-org/

Base path: /v1/library

Path-suffix (resource): /books

Target URL: http://mylibrary.com

Incoming request:

http://my-org/v1/library/books?author=kalam

Need to send it to target as:

http://mylibrary.com/search?auth_name=kalam

Here I need to change the path-suffix, or remove it from the incoming request so that I can apply a new one.

What is the easiest or recommended way to do this? I would like to avoid javascripting.

Solved Solved
2 10 12.9K
1 ACCEPTED SOLUTION

adas
Participant V

You need to add a javascript to set the pathsuffix to false:

context.setVariable("target.copy.pathsuffix", false)

Add the javascript policy in the target "preflow" and it should work. If you need to append something to the target, you can do that in the same javascript too.

View solution in original post

10 REPLIES 10

adas
Participant V

You need to add a javascript to set the pathsuffix to false:

context.setVariable("target.copy.pathsuffix", false)

Add the javascript policy in the target "preflow" and it should work. If you need to append something to the target, you can do that in the same javascript too.

Thanks Arghya, that worked.

btw, You can do the equivalent in an AssignMessage policy

<AssignMessage name='AM-PathSuffixFalse'>
  <AssignVariable>
    <Name>target.copy.pathsuffix</Name>
    <Value>false</Value>
  </AssignVariable> 
</AssignMessage>

For this to work, you must attach this policy in the target request flow. 

Not applicable

As you have mentioned in your question you want to avoid java script. In that case, you can also use below code snippets

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage name="AssignMessage.DisablePathCopy">
    <AssignVariable>
        <Name>target.copy.pathsuffix</Name>
        <Value>false</Value>
    </AssignVariable>
</AssignMessage>

@Muhammad Imran Khan

When I set this variable in Assignmessage / Target endpoint it is still copying pathsuffix to target endpoint URL. Can you please help?

You must attach this policy to the target request flow.

Is it possible to remove the path suffix, but not have it apply to every proxy endpoint. Meaning we just want to remove this suffix for a certain proxy endpoint.

Yes, you can do that by applying a condition around the AssignMessage step.

<Step>
  <Name>AM-DisablePathCopy</Name>
  <Condition>proxy.name == "proxy_endpoint_name"</Condition>
</Step>

Thank you!