Redirect to target's location
This commit is contained in:
11
src/app.ts
11
src/app.ts
@ -3,11 +3,16 @@ import { getLocationOfTarget } from './app.service';
|
||||
|
||||
let app = express();
|
||||
|
||||
app.get('/*', (req, res) => {
|
||||
app.get('/*', async (req, res) => {
|
||||
const target = req.url.slice(1);
|
||||
|
||||
const location = getLocationOfTarget(target);
|
||||
res.send(location);
|
||||
const location = await getLocationOfTarget(target);
|
||||
if (location) {
|
||||
res.redirect(location);
|
||||
}
|
||||
else {
|
||||
res.sendStatus(404);
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(3000, () => {
|
||||
|
Reference in New Issue
Block a user