mirror of
https://github.com/MedzikUser/gatsby-pingbot
synced 2024-08-15 03:20:27 +00:00
add blacklist
This commit is contained in:
parent
f11e1e707a
commit
a7bf878a82
2 changed files with 30 additions and 0 deletions
|
@ -3,8 +3,18 @@ import axios from 'axios'
|
|||
|
||||
import dbConnect from '../dbConnect'
|
||||
import URLModel from '../schema'
|
||||
import blacklist from './blacklist.json'
|
||||
|
||||
export default async function addURL(url: string, response: VercelResponse) {
|
||||
blacklist.forEach(b=> {
|
||||
if (url.includes(b)) {
|
||||
return response.status(400).json({
|
||||
success: false,
|
||||
message: 'URL in on blacklist'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// fetch url (e.g. check domain exist)
|
||||
try {
|
||||
await axios.get(url)
|
||||
|
|
20
lib/api/blacklist.json
Normal file
20
lib/api/blacklist.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
[
|
||||
"google.com",
|
||||
"google.co",
|
||||
"google.pl",
|
||||
"google.tk",
|
||||
"google.de",
|
||||
"google.cf",
|
||||
"google.bz",
|
||||
"youtube.com",
|
||||
"youtu.be",
|
||||
"twitter.com",
|
||||
"duckduckgo.com",
|
||||
"stackoverflow.com",
|
||||
"github.com",
|
||||
"gitlab.com",
|
||||
"reddit.com",
|
||||
"domains.google",
|
||||
"pingbot.cf",
|
||||
"magicuser.cf"
|
||||
]
|
Loading…
Reference in a new issue