Socket
Socket
Sign inDemoInstall

node-iframe

Package Overview
Dependencies
26
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-iframe

create a iframe on your server to bypass CORS issues. ( reverse engineer security issues )


Version published
Maintainers
1
Created

Readme

Source

node-iframe

A11yWatch

create iframes to bypass security issues on your server with node.js can also be used on the client

Installation

npm install node-iframe or yarn add node-iframe

How to use

On your server

const createIframe = require("node-iframe");

app.use(createIframe);

app.get("/iframe", (req, res) =>
  res.createIframe({
    url: req.query.url,
    baseHref: req.query.baseHref, // optional,
  })
);

On the client use directly in your iframe if your api is on the same server set the url below like this or if your using a framework like gatsby, nextjs, etc

<iframe src="/iframe/?url=https://www.etsy.com" />

You can even fetch the iframe directly by importing fetchFrame on the client or server.

const {
  fetchFrame,
  configureCacheControl,
  configureTemplates,
} = require("node-iframe");

// optional: configure cache-control, to disable cache set `disabled` to true - check https://github.com/node-cache/node-cache#options
// for more options and info
configureCacheControl({ stdTTL: 0, checkperiod: 600, disabled: false });

// optional: configure error-pages - check src/templates for more info
// 0: error, 1: not-found, 2: all templates - check src/templates/config for options
configureTemplates("<div>No Fish found</div>", 1);

async function fetchIframe() {
  return await fetchFrame("/iframe/?url=https://www.etsy.com");
}

Example

Params

Node iframe has one param Object with a url prop that is the url of the website and baseHref is optional property that will inject crossorigin="anonymous" onto all your script tags.

About

This project uses cheerio to manipulate html very fast. If your iframe fails to render thats where the security issues need to be reverse hacked by us using this project. As an alternative solution if the iframe fails to load simply fall back to the normal url of web page. You can fire this as an api request directly with fetch to get the website as html or use directly as your iframe src for best performance.

License

MIT

Keywords

FAQs

Last updated on 04 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc