Skip to content

Instantly share code, notes, and snippets.

@k-nishijima
Last active September 24, 2018 05:59
Show Gist options
  • Save k-nishijima/7d43e9230b40d9651e4d59634c8fba24 to your computer and use it in GitHub Desktop.
Save k-nishijima/7d43e9230b40d9651e4d59634c8fba24 to your computer and use it in GitHub Desktop.
const express = require('express');
const morgan = require('morgan');
const app = express();
app.use(morgan('combined'));
app.get(
'*',
(_, response) => {
response.setHeader('Content-Type', 'application/json');
response.send(JSON.stringify({ msg: 'hello world' }));
}
);
app.listen(
3000,
() => { console.log('start application server.') }
);
const http2https = express();
http2https.get(
'*',
(request, response) => {
response.redirect(301, `https://${request.hostname}${request.url}`);
}
);
http2https.listen(
3001,
() => { console.log('start redirect server.'); }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment