Javascript not running on local microgateway to overwrite target.url,TargetEndPoint override not working

Not applicable

I am trying to write an API proxy that will query a service discovery tool and route to a dynamic end point based on the result of the query.

This is the example i am following for the endpoint rewrite: http://docs.apigee.com/api-services/reference/javascript-policy

That seems to work when i hit the URL in the example: curl -i -H 'Content-Type: application/x-www-form-urlencoded'-X POST -d 'user=Will' http://myorg-test.apigee.net/js-example

But when I try to test my local micro gateway (which pulls in this example code from the Edge UI) the javascript doesn't seem to run and it always hits the default URL. This is what i am hitting locally curl -i -H 'Content-Type: application/x-www-form-urlencoded'-X POST -d 'user=Will' http://localhost:8000/js-example

Are there any settings that need to be enabled locally to allow javascript to run?

Solved Solved
1 4 282
1 ACCEPTED SOLUTION

Former Community Member
Not applicable

@Kyle Labbe

hmmm, yes, It can be a bit confusing for someone who is familiar with the API Proxy model, but ... Microgateway does not use any policies defined in the API Proxy (including JavaScript). All logic that runs in the microgateway is delivered via "plugins". Please refer here for how to write a custom plugin: http://docs.apigee.com/microgateway/latest/develop-custom-plugins

Plugins are configured (enabled or disabled) in the config.yaml file.

View solution in original post

4 REPLIES 4

Hey @Srinandan Sridhar

Would you like to address this question?

Former Community Member
Not applicable

@Kyle Labbe

hmmm, yes, It can be a bit confusing for someone who is familiar with the API Proxy model, but ... Microgateway does not use any policies defined in the API Proxy (including JavaScript). All logic that runs in the microgateway is delivered via "plugins". Please refer here for how to write a custom plugin: http://docs.apigee.com/microgateway/latest/develop-custom-plugins

Plugins are configured (enabled or disabled) in the config.yaml file.

Thank you, that explains why I was seeing that behavior. I will review the plugin documentation and try implementing my service that way.

@Former Community Member 

@Kyle Labbe

Do we have plugin to be used in edge microgateway which will dynamically update target.url in target endpoint in edgemicro proxy ? I am not sure how to develop this plugin.

I don't know JS, but still some algorithmic steps would help, already gone through the official post of apigee.