Skip to content

Instantly share code, notes, and snippets.

@reepush
Created July 20, 2015 13:24
Show Gist options
  • Save reepush/2f364ce3e4d52f61f0bb to your computer and use it in GitHub Desktop.
Save reepush/2f364ce3e4d52f61f0bb to your computer and use it in GitHub Desktop.
CORS proxy
var express = require('express')
var request = require('request')
var app = express()
app.get('/', function(req, res) {
var src = req.query.src
res.header('Access-Control-Allow-Origin', '*')
if (!src) { res.send(''); return }
options = {
url: src,
headers: {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0',
}
}
request(options, function(err, response, body) {
res.send(body)
})
})
app.listen(3000, function() {
console.log('Listening on 3000 port...')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment