lbry-desktop/web/middleware/iframe-destroyer.js
Thomas Zarebczan 71589721ef
Fix logic
2022-03-03 10:23:40 -05:00

16 lines
415 B
JavaScript

const PAGES = require('../../ui/constants/pages');
async function iframeDestroyerMiddleware(ctx, next) {
const {
request: { path },
} = ctx;
const decodedPath = decodeURIComponent(path);
if (!(decodedPath.startsWith(`/$/${PAGES.EMBED}`) || decodedPath.startsWith(`/$/api/content/v1/get`))) {
ctx.set('X-Frame-Options', 'DENY');
}
return next();
}
module.exports = iframeDestroyerMiddleware;