Skip to content

Instantly share code, notes, and snippets.

@ArnaudD

ArnaudD/Procfile Secret

Created September 1, 2014 18:48
Show Gist options
  • Save ArnaudD/d776b692b5f1ee64257e to your computer and use it in GitHub Desktop.
Save ArnaudD/d776b692b5f1ee64257e to your computer and use it in GitHub Desktop.
ClicRDV Proxy on Heroku
npm install
git push heroku master
var express = require('express')
var app = express();
var proxy = require('proxy-middleware');
var url = require('url');
app.set('port', (process.env.PORT || 5000))
app.get('/', function(request, response) {
response.send('Hello World!')
})
app.all('/*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "http://run.plnkr.co");
res.header("Access-Control-Allow-Credentials", "true");
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header("Access-Control-Allow-Headers", req.headers["access-control-request-headers"]);
// intercept OPTIONS method
if ('OPTIONS' == req.method) {
res.send(200);
}
else {
req.headers['origin'] = 'https://www.clicrdv.com';
req.headers['referer'] = 'https://www.clicrdv.com';
next();
}
});
app.use('/api', proxy(url.parse('https://www.clicrdv.com/api')));
app.use('/pro', proxy(url.parse('https://www.clicrdv.com/pro')));
app.listen(app.get('port'), function() {
console.log("Node app is running at localhost:" + app.get('port'))
})
{
"name": "peaceful-coast-9239",
"version": "0.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"connect": "^3.1.1",
"express": "~3.4.x",
"proxy-middleware": "^0.5.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
web: node index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment