2015-08-20 23:22:57 +01:00
|
|
|
import { parse } from 'url';
|
2015-06-03 21:45:54 -07:00
|
|
|
import request from 'superagent';
|
2014-12-04 22:50:30 +00:00
|
|
|
|
2015-08-20 23:22:57 +01:00
|
|
|
export default function* (next) {
|
|
|
|
const url = 'http://' + this.request.url.substr(8);
|
|
|
|
const parsed = parse(url);
|
2014-12-04 22:50:30 +00:00
|
|
|
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;
|
2014-12-04 22:50:30 +00:00
|
|
|
}
|
|
|
|
};
|