Skip to content

Instantly share code, notes, and snippets.

@NickNaso
Created January 18, 2017 20:55
Show Gist options
  • Save NickNaso/5b66fa6471f8cc181e19875bda88751e to your computer and use it in GitHub Desktop.
Save NickNaso/5b66fa6471f8cc181e19875bda88751e to your computer and use it in GitHub Desktop.
ExpressJS relative redirect For more info take alook here: http://expressjs.com/en/4x/api.html#res.redirect
'use strict'
const express = require('express')
const http = require('http')
const app = express()
////////////////////////////////// ROUTER /////////////////////////////////////
const router = express.Router()
router.get('/', (req, res) => {
res.send('HOME')
})
router.get('/about', (req, res) => {
res.send('ABOUT')
})
router.get('/contactus', (req, res) => {
// Redirect to /test
// See relative redirect at http://expressjs.com/en/4x/api.html#res.redirect
res.redirect('.')
})
////////////////////////////////////////////////////////////////////////////////
app.use('/test', router)
http.createServer(app).listen(5000, '0.0.0.0', () => {
console.log('Something magic happens on port 5000 ...')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment