WIP: Successful Google Auth, broke pretty much everything else in the process
This commit is contained in:
19
server/api/middlewares/methodOverride.js
Normal file
19
server/api/middlewares/methodOverride.js
Normal file
@ -0,0 +1,19 @@
|
||||
// @flow
|
||||
import queryString from 'query-string';
|
||||
import { type Context } from 'koa';
|
||||
|
||||
export default function methodOverride() {
|
||||
return async function methodOverrideMiddleware(
|
||||
ctx: Context,
|
||||
next: () => Promise<*>
|
||||
) {
|
||||
if (ctx.method === 'POST') {
|
||||
// $FlowFixMe
|
||||
ctx.body = ctx.request.body;
|
||||
} else if (ctx.method === 'GET') {
|
||||
ctx.method = 'POST'; // eslint-disable-line
|
||||
ctx.body = queryString.parse(ctx.querystring);
|
||||
}
|
||||
return next();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user