Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript Plugin doesn't allow hostname rewrite #6791

Open
iamdjones opened this issue Dec 19, 2024 · 0 comments
Open

Javascript Plugin doesn't allow hostname rewrite #6791

iamdjones opened this issue Dec 19, 2024 · 0 comments
Labels

Comments

@iamdjones
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant