Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-iframe

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

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 )

  • 1.5.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34
decreased by-62.22%
Maintainers
1
Weekly downloads
 
Created
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

How to use

as express middleware

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

app.use(createIframe);

app.get("/iframe", (req, res) =>
  res.createIframe({
    url: req.query.url,
    baseHref: req.query.baseHref, // optional: determine how to control link redirects,
    config: JSON.parse(req.query.config), // optional: determine element cors or inlining #shape src/iframe.ts#L34
  })
);

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 or non-express apps

<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 } = require("node-iframe");

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

Configure how to handle resources for all request

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

// optional: configure if elements should be inlined, cors, etc, this combines with the `config` param
configureResourceControl({
  inline: { script: true, link: false },
  cors: { script: true },
});
// 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);

Example

License

MIT

Keywords

FAQs

Package last updated on 08 Oct 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc