From 00a17ed5d4ee7f3720dcb5e5b8c8804be3dcb23b Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 9 Oct 2020 14:20:34 +0900 Subject: [PATCH] =?UTF-8?q?/streaming=E3=81=AB=E9=9D=9EWebSocket=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=82=B9=E3=83=88=E3=81=8C=E6=9D=A5=E3=82=8B?= =?UTF-8?q?=E3=81=A8=E3=81=8A=E3=81=8B=E3=81=97=E3=81=8F=E3=81=AA=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=20Fix=20#6718=20(#6719)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/scripts/stream.ts | 8 +++++++- src/server/web/index.ts | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/client/scripts/stream.ts b/src/client/scripts/stream.ts index 8a525ba00..defb22af8 100644 --- a/src/client/scripts/stream.ts +++ b/src/client/scripts/stream.ts @@ -3,6 +3,7 @@ import { EventEmitter } from 'eventemitter3'; import ReconnectingWebsocket from 'reconnecting-websocket'; import { wsUrl } from '../config'; import MiOS from '../mios'; +import { query as urlQuery } from '../../prelude/url'; /** * Misskey stream connection @@ -21,7 +22,12 @@ export default class Stream extends EventEmitter { const user = os.store.state.i; - this.stream = new ReconnectingWebsocket(wsUrl + (user ? `?i=${user.token}` : ''), '', { minReconnectionDelay: 1 }); // https://github.com/pladaria/reconnecting-websocket/issues/91 + const query = urlQuery({ + i: user?.token, + _t: Date.now(), + }); + + this.stream = new ReconnectingWebsocket(`${wsUrl}?${query}`, '', { minReconnectionDelay: 1 }); // https://github.com/pladaria/reconnecting-websocket/issues/91 this.stream.addEventListener('open', this.onOpen); this.stream.addEventListener('close', this.onClose); this.stream.addEventListener('message', this.onMessage); diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 507ddac3c..58e764ee1 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -358,6 +358,12 @@ router.get('/flush', async ctx => { await ctx.render('flush'); }); +// streamingに非WebSocketリクエストが来た場合にbase htmlをキャシュ付きで返すと、Proxy等でそのパスがキャッシュされておかしくなる +router.get('/streaming', async ctx => { + ctx.status = 503; + ctx.set('Cache-Control', 'private, max-age=0'); +}); + // Render base html for all requests router.get('(.*)', async ctx => { const meta = await fetchMeta();