Created
January 18, 2017 20:55
-
-
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
This file contains hidden or 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' | |
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