lbry-desktop/web/middleware/iframe-destroyer.js

17 lines
415 B
JavaScript
Raw Normal View History

2021-02-18 22:57:52 +01:00
const PAGES = require('../../ui/constants/pages');
async function iframeDestroyerMiddleware(ctx, next) {
const {
request: { path },
} = ctx;
2021-02-19 15:30:28 +01:00
const decodedPath = decodeURIComponent(path);
2021-02-18 22:57:52 +01:00
2022-03-03 16:23:40 +01:00
if (!(decodedPath.startsWith(`/$/${PAGES.EMBED}`) || decodedPath.startsWith(`/$/api/content/v1/get`))) {
2021-02-18 22:57:52 +01:00
ctx.set('X-Frame-Options', 'DENY');
}
return next();
}
module.exports = iframeDestroyerMiddleware;