Use proxy instead of weserv for url-preview images (#4466)

This commit is contained in:
MeiMei
2019-03-11 01:03:09 +09:00
committed by syuilo
parent c6cdfa2f5a
commit 4d425fc8a4
2 changed files with 9 additions and 2 deletions

View File

@ -3,6 +3,8 @@ import * as request from 'request-promise-native';
import summaly from 'summaly';
import fetchMeta from '../../misc/fetch-meta';
import Logger from '../../services/logger';
import config from '../../config';
import { query } from '../../prelude/url';
const logger = new Logger('url-preview');
@ -44,7 +46,10 @@ module.exports = async (ctx: Koa.BaseContext) => {
function wrap(url: string): string {
return url != null
? url.match(/^https?:\/\//)
? `https://images.weserv.nl/?url=${encodeURIComponent(url.replace(/^http:\/\//, '').replace(/^https:\/\//, 'ssl:'))}&w=200&h=200`
? `${config.url}/proxy/preview.jpg?${query({
url,
preview: '1'
})}`
: url
: null;
}