2019-02-04 11:01:36 -07:00
|
|
|
/**
|
|
|
|
* Media Proxy
|
|
|
|
*/
|
|
|
|
|
2023-01-12 21:40:33 -07:00
|
|
|
import Koa from "koa";
|
|
|
|
import cors from "@koa/cors";
|
|
|
|
import Router from "@koa/router";
|
|
|
|
import { proxyMedia } from "./proxy-media.js";
|
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) => {
|
2023-01-12 21:40:33 -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();
|
|
|
|
|
2023-01-12 21:40:33 -07:00
|
|
|
router.get("/:url*", proxyMedia);
|
2019-02-04 11:01:36 -07:00
|
|
|
|
|
|
|
// Register router
|
|
|
|
app.use(router.routes());
|
|
|
|
|
2022-02-26 19:07:39 -07:00
|
|
|
export default app;
|