From 73831a80db8932d2df3b6632fcb1be4095e884a1 Mon Sep 17 00:00:00 2001 From: Ken Mickles Date: Fri, 14 Sep 2012 17:36:56 -0400 Subject: [PATCH] First commit --- Procfile | 1 + README.md | 8 ++++++-- package.json | 11 +++++++++++ web.js | 12 ++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Procfile create mode 100644 package.json create mode 100644 web.js diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..d1913eb --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: node web.js \ No newline at end of file diff --git a/README.md b/README.md index 5f9d765..c5d23ed 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ -heroku-redirect -=============== \ No newline at end of file +Simple node app to redirect all requests from a Heroku app to a new URL. I've needed this more times than I should have. + +## Configuration +``` +heroku config:add NEW_BASE_URL=http://example.com +``` \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..7bdf8db --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "node-example", + "version": "0.0.1", + "dependencies": { + "express": "2.5.x" + }, + "engines": { + "node": "0.8.x", + "npm": "1.1.x" + } +} \ No newline at end of file diff --git a/web.js b/web.js new file mode 100644 index 0000000..987d0a5 --- /dev/null +++ b/web.js @@ -0,0 +1,12 @@ +var express = require('express'); + +var app = express.createServer(express.logger()); + +app.get('*', function(request, response) { + response.redirect(process.env.NEW_BASE_URL + request.url) +}); + +var port = process.env.PORT || 5000; +app.listen(port, function() { + console.log("Listening on " + port); +}); \ No newline at end of file