JohanObrink / intercept-proxy

16 stars 7 forks source link

Ignore request parameters? #3

Open srissel opened 10 years ago

srissel commented 10 years ago

Hi,

many thanks for your very interesting proxy implementation. I've got one small question: Our application server appends a URL parameter with last modified timestamp /.../path/to/myJS.js?noCache=1410955520 to each request, to prevent the browser from caching outdated JS files.

This seems to hinder intercept-proxy to map local files to remote files. Is it possible to make intercept-proxy ignore these URL parameters?

Many thanks in advance, Sascha.

JohanObrink commented 10 years ago

Hi,

There's an example in the readme for this:

proxy.createServer({
  host: 'knowyourmeme.com',
  methods: 'GET,POST',           // will intercept GET and POST but not PUT and DELETE
  supressQuery: true             // remove query parameters from url when looking for local file
});

Basically this tells the proxy to ignore any query data.

srissel commented 10 years ago

Johan,

thanks for your answer.

Today I was able to follow that topic again. When setting "suppressQuery", I discovered a bug in proxy.js: starting lines 29:

this.options = {
  host: options.host,
  port: options.port || 80,
  path: options.path || '',
  headers: options.headers || {},
  methods: options.methods || 'GET',
  supressQuery: options.supressQuery || false
};

options methods and suppressQuery were hard coded and didn't use the actual parameters passed from instantiation. On my local system, it is working fine. I created a pull request for that - please merge it with he core.

Thanks in advance, Sascha.