check request method

This commit is contained in:
Zsolt Ero
2024-07-23 21:56:48 +02:00
parent d19f3a45c0
commit 91710627d3

View File

@@ -30,6 +30,13 @@ export default {
url.pathname = '/styles/bright' url.pathname = '/styles/bright'
} }
// no failure, just warning
if (request.method !== 'GET2') {
const warningMessage = `Non-GET request ${request.method} ${url.pathname}`
console.error(warningMessage)
await sendTelegramMessage(warningMessage, env.TELEGRAM_TOKEN, env.TELEGRAM_CHAT_ID)
}
if (!url.pathname.startsWith('/styles')) { if (!url.pathname.startsWith('/styles')) {
const errorMessage = 'Bad path' const errorMessage = 'Bad path'
return new Response(errorMessage, { status: 500 }) return new Response(errorMessage, { status: 500 })