In an Apigee API Proxy, Unable to route to new target even after rewriting “target.url” via a JavaScript policy

I have a node.js application(deployed using Hosted Target) (with query parameter). What I am trying to do is, When I hit my current url I want to redirect it to a new url (my cloud function url). I have used a javascript policy for it. The script is something like:

var url = '';


I have my javascript policy on Targetendpoint Response flow.

But I am getting an error:

Cannot GET /