Skip to content

Added various options, https support - #6

Open
typpo wants to merge 2 commits into
mysociety:masterfrom
typpo:master
Open

Added various options, https support#6
typpo wants to merge 2 commits into
mysociety:masterfrom
typpo:master

Conversation

@typpo

@typpo typpo commented Sep 19, 2012

Copy link
Copy Markdown

I refactored things into an ImageProxy class that you can use like so:

  var myproxy = new ImageProxy({
    validMimeTypes: ['image/png'],
    hostsWhitelist: ['mysite.com', 'images.mysite.com'],
    headers: {'Cache-Control': 'max-age=31536000'},
  });

  // mount the proxy at '/proxy'
  app.use( '/proxy', myproxy.requestHandler );

We accept the following options:

  • validMimeTypes - defaults to jpg/jpeg, png, gif
  • hostsWhitelist - defaults to the same host only
  • headers - default to no additional headers besides content-type

I also added support for proxying images over https.

I realize that these changes are not backwards compatible so I understand if you'd prefer to keep things the old way. I needed these features, so I went ahead and built them anyway. Thank you for starting this project!

Ian and others added 2 commits September 19, 2012 14:47
Valid options:
- hostsWhitelist {array} - list of allowed hosts.  If not specified,
    proxy requests are restricted to the same host.
- validMimeTypes {array} - list of allowed mime types.
- headers {object} - map of http response headers.
@jpmckinney

Copy link
Copy Markdown

+1 for hostsWhitelist

@jpmckinney

Copy link
Copy Markdown

FYI I ended up writing my own tiny app: https://github.com/opennorth/image-proxy/blob/master/web.js

It does the tempfile management more sanely by taking full advantage of gm's input stream features.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants