Skip to content

Instantly share code, notes, and snippets.

@bernardeli
Created June 19, 2014 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bernardeli/4cf85ccfde7929b0c893 to your computer and use it in GitHub Desktop.
Save bernardeli/4cf85ccfde7929b0c893 to your computer and use it in GitHub Desktop.
Redirection JS
'use strict';
var express = require('express'),
request = require('superagent'),
app = express(),
config = require('./config');
app.get('*', function(req, res){
var cloudfrontUrl = config[req.url];
if (cloudfrontUrl === undefined) {
res.redirect('/forum');
return;
}
res.writeHead(200, { 'Content-Type' : 'text/html' });
request
.get(cloudfrontUrl)
.pipe(res);
});
app.listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment