Added noindex header to all shorturl routes
continuous-integration/drone/push Build is passing Details

ref #2
This commit is contained in:
Nicolai Ort 2021-09-25 16:59:28 +02:00
parent b871e4295d
commit 0a8945a294
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
1 changed files with 5 additions and 0 deletions

View File

@ -74,23 +74,27 @@ fastify.decorate('verifyJWT', function async(request, reply, done) {
//Automagic Amazn redirects on /a/
fastify.get('/a/:id', async (req, res) => {
res.header("X-Robots-Tag","noindex, nofollow");
res.redirect(302, `https://amazon.de/dp/${req.params.id}`)
await knex('visits').insert({ shortcode: req.params.id, provider: 'a' });
})
//Automagic Youtube redirects on /yt/
fastify.get('/yt/:id', async (req, res) => {
res.header("X-Robots-Tag","noindex, nofollow");
res.redirect(302, `https://youtu.be/${req.params.id}`)
await knex('visits').insert({ shortcode: req.params.id, provider: 'yt' });
})
//Automagic Youtube Playlist redirects on /ytpl/
fastify.get('/ytpl/:id', async (req, res) => {
res.header("X-Robots-Tag","noindex, nofollow");
res.redirect(302, `https://youtube.com/playlist?list=${req.params.id}`)
await knex('visits').insert({ shortcode: req.params.id, provider: 'ytpl' });
})
//Automagic ebay item redirects on /e/
fastify.get('/e/:id', async (req, res) => {
res.header("X-Robots-Tag","noindex, nofollow");
res.redirect(302, `https://ebay.de/itm/${req.params.id}`)
await knex('visits').insert({ shortcode: req.params.id, provider: 'e' });
})
@ -98,6 +102,7 @@ fastify.get('/e/:id', async (req, res) => {
//Normal shorturls
fastify.get('/:shortcode', async (req, res) => {
const shortcode = req.params.shortcode;
res.header("X-Robots-Tag","noindex, nofollow");
//This should never happen but better safe than 500
if (!shortcode) {