pass-cors

1.1.0 • Public • Published

pass-cors

A simple proxy to load CORS blocked files

Must be used in an express server environment

$ npm i pass-cors

  • Can be Used with any file type
  • Just two lines of integration
  • Eliminate third party proxy server dependency
  • No need of a separate server to be hosted just for proxy
  • This will function as a part of your current server and opens up a custom path set by the user


Server Side

//Boilerplate
const express = require('express')
const app = express()


//Main
const proxy = require('pass-cors')
app.use('/proxy', proxy);  //You can customise the route name


//Boilerplate
app.listen(process.env.PORT||8080)


Client Side


Before

<img src="https://corsblockedimage.com/cat.png">

<script src="https://corsblockedscript.com/sometool.js"></script>

<link href="https://corsblockedcss.com/style.css" rel="stylesheet">

After

<img src="/proxy?url=https://corsblockedimage.com/cat.png">

<script src="/proxy?url=https://corsblockedscript.com/sometool.js"></script>

<link href="/proxy?url=https://corsblockedcss.com/style.css" rel="stylesheet">

Thats how easy it is to load a CORS blocked elements on your frontend

Package Sidebar

Install

npm i pass-cors

Weekly Downloads

3

Version

1.1.0

License

ISC

Unpacked Size

4.62 kB

Total Files

3

Last publish

Collaborators

  • nithinsgowda