[mastodon-client] Set correct access-control-expose-headers response header

This commit is contained in:
Laura Hausmann 2023-10-07 00:13:23 +02:00
parent 081b836e92
commit 3bc4afec77
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605
2 changed files with 12 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import { CacheMiddleware } from "@/server/api/mastodon/middleware/cache.js";
import { KoaBodyMiddleware } from "@/server/api/mastodon/middleware/koa-body.js";
import { NormalizeQueryMiddleware } from "@/server/api/mastodon/middleware/normalize-query.js";
import { PaginationMiddleware } from "@/server/api/mastodon/middleware/pagination.js";
import { SetHeadersMiddleware } from "@/server/api/mastodon/middleware/set-headers.js";
export const logger = apiLogger.createSubLogger("mastodon");
export type MastoContext = RouterContext & DefaultContext;
@ -37,6 +38,7 @@ export function setupMastodonApi(router: Router): void {
function setupMiddleware(router: Router): void {
router.use(KoaBodyMiddleware());
router.use(SetHeadersMiddleware);
router.use(CatchErrorsMiddleware);
router.use(NormalizeQueryMiddleware);
router.use(PaginationMiddleware);

View File

@ -0,0 +1,10 @@
import { MastoContext } from "@/server/api/mastodon/index.js";
const headers = {
"Access-Control-Expose-Headers": "Link,Connection,Sec-Websocket-Accept,Upgrade"
};
export async function SetHeadersMiddleware(ctx: MastoContext, next: () => Promise<any>) {
ctx.set(headers);
await next();
}