/streamingに非WebSocketリクエストが来るとおかしくなるのを修正 Fix #6718 (#6719)

This commit is contained in:
MeiMei 2020-10-09 14:20:34 +09:00 committed by GitHub
parent b594366f06
commit 00a17ed5d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -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);

View File

@ -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();