chore: Auto reload frontend of client is out of date (#1270)
* Move editor version to header Add editor version check for API endpoints * fix: Editor update auto-reload Bump RME * fix: Only redirect if editor header exists * lint
This commit is contained in:
17
server/api/middlewares/editor.js
Normal file
17
server/api/middlewares/editor.js
Normal file
@ -0,0 +1,17 @@
|
||||
// @flow
|
||||
import { type Context } from 'koa';
|
||||
import pkg from 'rich-markdown-editor/package.json';
|
||||
import { EditorUpdateError } from '../../errors';
|
||||
|
||||
export default function editor() {
|
||||
return async function editorMiddleware(ctx: Context, next: () => Promise<*>) {
|
||||
const editorVersion = ctx.headers['x-editor-version'];
|
||||
|
||||
// As the client can only ever be behind the server there's no need for a
|
||||
// more strict check of version infront/behind here
|
||||
if (editorVersion && editorVersion !== pkg.version) {
|
||||
throw new EditorUpdateError();
|
||||
}
|
||||
return next();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user