Created
June 19, 2014 03:48
-
-
Save bernardeli/4cf85ccfde7929b0c893 to your computer and use it in GitHub Desktop.
Redirection JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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