rudeshark.net/packages/backend/src/server/proxy/index.ts
syuilo d071d18dd7
refactor: Use ESM (#8358)
* wip

* wip

* fix

* clean up

* Update tsconfig.json

* Update activitypub.ts

* wip
2022-02-27 11:07:39 +09:00

27 lines
528 B
TypeScript

/**
* Media Proxy
*/
import Koa from 'koa';
import cors from '@koa/cors';
import Router from '@koa/router';
import { proxyMedia } from './proxy-media.js';
// Init app
const app = new Koa();
app.use(cors());
app.use(async (ctx, next) => {
ctx.set('Content-Security-Policy', `default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'`);
await next();
});
// Init router
const router = new Router();
router.get('/:url*', proxyMedia);
// Register router
app.use(router.routes());
export default app;