Cache failed url-preview (apply to proxy/client) (#2154)

This commit is contained in:
MeiMei 2018-08-11 18:04:59 +09:00 committed by syuilo
parent 63720d1810
commit a05924e9a3
2 changed files with 11 additions and 7 deletions

View file

@ -104,13 +104,15 @@ export default Vue.extend({
} }
fetch('/url?url=' + encodeURIComponent(this.url)).then(res => { fetch('/url?url=' + encodeURIComponent(this.url)).then(res => {
res.json().then(info => { res.json().then(info => {
this.title = info.title; if (info.url != null) {
this.description = info.description; this.title = info.title;
this.thumbnail = info.thumbnail; this.description = info.description;
this.icon = info.icon; this.thumbnail = info.thumbnail;
this.sitename = info.sitename; this.icon = info.icon;
this.sitename = info.sitename;
this.fetching = false; this.fetching = false;
}
}); });
}); });
} }

View file

@ -14,7 +14,9 @@ module.exports = async (ctx: Koa.Context) => {
ctx.body = summary; ctx.body = summary;
} catch (e) { } catch (e) {
ctx.status = 500; ctx.status = 200;
ctx.set('Cache-Control', 'max-age=86400, immutable');
ctx.body = '{}';
} }
}; };