2019-02-04 19:01:36 +01:00
|
|
|
/**
|
|
|
|
* Media Proxy
|
|
|
|
*/
|
|
|
|
|
2022-02-27 03:07:39 +01:00
|
|
|
import Koa from 'koa';
|
|
|
|
import cors from '@koa/cors';
|
|
|
|
import Router from '@koa/router';
|
|
|
|
import { proxyMedia } from './proxy-media.js';
|
2019-02-04 19:01:36 +01:00
|
|
|
|
|
|
|
// Init app
|
|
|
|
const app = new Koa();
|
|
|
|
app.use(cors());
|
2021-08-24 06:08:20 +02:00
|
|
|
app.use(async (ctx, next) => {
|
2022-01-28 18:23:18 +01:00
|
|
|
ctx.set('Content-Security-Policy', `default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'`);
|
2021-08-24 06:08:20 +02:00
|
|
|
await next();
|
|
|
|
});
|
2019-02-04 19:01:36 +01:00
|
|
|
|
|
|
|
// Init router
|
|
|
|
const router = new Router();
|
|
|
|
|
|
|
|
router.get('/:url*', proxyMedia);
|
|
|
|
|
|
|
|
// Register router
|
|
|
|
app.use(router.routes());
|
|
|
|
|
2022-02-27 03:07:39 +01:00
|
|
|
export default app;
|