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