My main function is I am creating a link-shortening app. When someone entered a long URL, it will give a short URL. If the user clicked on the short link it will search for the long URL on the DB and redirect it to the long URL.
Meantime I want to get the click count and clicked user's OS.
I am currently using current code :
app.get('/:shortUrl', async (req, res) => {
const shortUrl = await ShortUrl.findOne({short: req.params.shortUrl})
if (shortUrl == null) return res.sendStatus(404)
res.redirect(shortUrl.full)
})
findOne is finding the Long URL on the database using ShortID. I used mongoDB here
My questions are :
- Are there multiple redirect methods in JS?
- Is this method work if there is a high load?
- Any other methods I can use to achieve the same result?
- What other facts that matter on redirect time
- What is 'No Redirection Tracking'?
This is a really long question, Thanks to those who invested their time in this.