1.1.0 • Published 3 years ago

pass-cors v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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">