diff --git a/.config/example.yml b/.config/example.yml index 9ea048f70..ecb1dd193 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -138,3 +138,6 @@ drive: # Clustering # clusterLimit: 1 + +# Summaly proxy +# summalyProxy: "http://example.com" diff --git a/src/config/types.ts b/src/config/types.ts index f220e1582..a1dc9a5bd 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -62,6 +62,8 @@ export type Source = { */ ghost?: string; + summalyProxy?: string; + accesslog?: string; twitter?: { consumer_key: string; diff --git a/src/server/web/url-preview.ts b/src/server/web/url-preview.ts index e96eb309f..41ca6bad8 100644 --- a/src/server/web/url-preview.ts +++ b/src/server/web/url-preview.ts @@ -1,11 +1,20 @@ import * as Koa from 'koa'; +import * as request from 'request-promise-native'; import summaly from 'summaly'; +import config from '../../config'; module.exports = async (ctx: Koa.Context) => { try { - const summary = await summaly(ctx.query.url, { + const summary = config.summalyProxy ? await request.get({ + url: config.summalyProxy, + qs: { + url: ctx.query.url + }, + json: true + }) : await summaly(ctx.query.url, { followRedirects: false }); + summary.icon = wrap(summary.icon); summary.thumbnail = wrap(summary.thumbnail);