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