combine.fm/routes/itunes-proxy.js

15 lines
382 B
JavaScript
Raw Normal View History

2015-08-20 23:22:57 +01:00
import { parse } from 'url';
2015-06-03 21:45:54 -07:00
import request from 'superagent';
2015-08-20 23:22:57 +01:00
export default function* (next) {
const url = 'http://' + this.request.url.substr(8);
const parsed = parse(url);
if (parsed.host.match(/mzstatic\.com/)) {
2015-08-20 23:22:57 +01:00
const proxyResponse = yield request.get(url);
2015-06-03 21:45:54 -07:00
this.set(proxyResponse.headers);
this.body = proxyResponse.body;
} else {
yield next;
}
};