this is super cursed

This commit is contained in:
cutestnekoaqua 2023-02-10 23:00:15 +01:00
parent f2b014b4a8
commit 838ca1841a
No known key found for this signature in database
GPG Key ID: 6BF0964A5069C1E0
2 changed files with 9 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import { Instances, AccessTokens, Users } from "@/models/index.js";
import config from "@/config/index.js";
import endpoints from "./endpoints.js";
import compatibility from "./compatibility.js";
import {koaBody} from "koa-body";
import handler from "./api-handler.js";
import signup from "./private/signup.js";
import signin from "./private/signin.js";
@ -35,6 +36,13 @@ app.use(async (ctx, next) => {
await next();
});
app.use(
koaBody({
json: false,
multipart: true
})
);
app.use(
bodyParser({
// リクエストが multipart/form-data でない限りはJSONだと見なす

View File

@ -146,8 +146,7 @@ router.post("/oauth/token", koaBody({
multipart: true
}), async (ctx) => {
const body: any = ctx.request.body;
//const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
const BASE_URL = "http://localhost:3000";
const BASE_URL = `${ctx.request.protocol}://${ctx.request.hostname}`;
const generator = (megalodon as any).default;
const client = generator('misskey', BASE_URL, null) as MegalodonInterface;
const m = body.code.match(/^[a-zA-Z0-9-]+/);