Skip to content

Commit a91d550

Browse files
add new middleware, block RU and BY
1 parent 0a8c604 commit a91d550

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

server/middleware/2_block_geo.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { createError, defineEventHandler } from 'h3'
2+
import { COUNTRY_HEADER_NAME } from '~~/server/tracking/const'
3+
4+
const blockedCountries = ["RU", "BY"]
5+
6+
export default defineEventHandler((event) => {
7+
const country = event.node.req.headers[COUNTRY_HEADER_NAME] as string
8+
9+
if (blockedCountries.includes(country)) {
10+
throw createError({
11+
statusCode: 403,
12+
statusMessage: 'Forbidden'
13+
})
14+
}
15+
})

0 commit comments

Comments
 (0)