2019-02-04 20:01:36 +02:00
|
|
|
/**
|
|
|
|
* Media Proxy
|
|
|
|
*/
|
|
|
|
|
|
|
|
import * as Koa from 'koa';
|
|
|
|
import * as cors from '@koa/cors';
|
2019-09-26 23:50:34 +03:00
|
|
|
import * as Router from '@koa/router';
|
2021-08-19 15:55:45 +03:00
|
|
|
import { proxyMedia } from './proxy-media';
|
2019-02-04 20:01:36 +02:00
|
|
|
|
|
|
|
// Init app
|
|
|
|
const app = new Koa();
|
|
|
|
app.use(cors());
|
2021-08-24 07:08:20 +03:00
|
|
|
app.use(async (ctx, next) => {
|
|
|
|
ctx.set('Content-Security-Policy', `default-src 'none'; style-src 'unsafe-inline'`);
|
|
|
|
await next();
|
|
|
|
});
|
2019-02-04 20:01:36 +02:00
|
|
|
|
|
|
|
// Init router
|
|
|
|
const router = new Router();
|
|
|
|
|
|
|
|
router.get('/:url*', proxyMedia);
|
|
|
|
|
|
|
|
// Register router
|
|
|
|
app.use(router.routes());
|
|
|
|
|
|
|
|
module.exports = app;
|