simple redirect node.js

علی ذوالفقار
1401/11/12 11:29:33 (353)
const http = require('http'); 
const url = 'https://TargetUrl.com';

const server = http.createServer((req, res) => {
    console.log('Redirect to ' , url);    // log activity
    res.writeHead(302, {'Location': url});// redirect
    res.end();
});

server.listen(81); // start server 
Back