summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/proxy/index.ts
blob: 506ba10ef11b225f6ae889bd0b79ccce93ccdb00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
 * 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;