Skip to content

Javascript Plugin doesn't allow hostname rewrite #6791

Open
@iamdjones

Description

Branch/Environment/Version

  • Branch/Version: master
  • Environment: Hybrid

Describe the bug
Javascript Plugins that rewrite hostname get overwritten with upstream configured in the api-def when sending outbound request.

Reproduction steps
Steps to reproduce the behavior:

  1. Add custom javascript plugin
var hostnameRewriteMiddleware = new TykJS.TykMiddleware.NewMiddleware({});

hostnameRewriteMiddleware.NewProcessRequest(function(request,session,config){
   
    request.URL = "https://httpbin.org" + request.URL;;

    return hostnameRewriteMiddleware.ReturnData(request, session.meta_data);
});
  1. Add api test-api.json
  2. Execute curl command "curl http://localhost:5000/test-api"

Actual behavior
The following outbound request (the configured upstream) is executed and returned: http://example.org/

Expected behavior
The following outbound request (with re-written hostname) is executed and returned: https://httpbin.org/

Logs (debug mode or log file):
tyk-gateway.log
Example output from the logs showing "Upstream request URL" with the hostname rewritten by the custom js plugin, and the final "Outbound request URL" with the api-def configured upstream hostname.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions