Follow up question on setting Host header in APIGee microgate-way using custom plugin

Hi,

I had posted this question yesterday, got reply to use custom plugin to set Host header.
https://www.googlecloudcommunity.com/gc/Apigee/Javascript-set-Host-header-policy-works-fine-in-APIGe... 

The suggested solution is not working, needed help to fix this issue.

Custom Plugin code to set header - index.js
Micro-gateway is able to pick this plugin but Host is not modified or updated.
@tapasthakkar@dchiesa1 

'use strict';
var debug = require('debug')

module.exports.init = function(config, logger, stats) {

  return {

	onrequest: function(req, res, data, next) {
      req.headers['host'] = 'nginx.amadeus.local';
      next();
    }
  };
}

 

Solved Solved
0 2 160
1 ACCEPTED SOLUTION

Can you try

    onrequest: function(req, res, data, next) {
      // req.headers['host'] = 'nginx.amadeus.local';
      req.targetHostname = 'nginx.amadeus.local';
      next();
    }

View solution in original post

2 REPLIES 2

Can you try

    onrequest: function(req, res, data, next) {
      // req.headers['host'] = 'nginx.amadeus.local';
      req.targetHostname = 'nginx.amadeus.local';
      next();
    }

Thanks for the suggestion, it works.