Add optional HTML response for IUAM
All checks were successful
CI / release (push) Successful in 2m44s
All checks were successful
CI / release (push) Successful in 2m44s
This commit is contained in:
7
index.js
7
index.js
@@ -103,6 +103,9 @@ app.post('/cloudflare', async (req, res) => {
|
||||
if (data.user_agent && typeof data.user_agent !== 'string') {
|
||||
return res.status(400).json({ message: 'Bad Request: invalid user_agent' })
|
||||
}
|
||||
if (typeof data.include_html !== 'undefined' && typeof data.include_html !== 'boolean') {
|
||||
return res.status(400).json({ message: 'Bad Request: invalid include_html' })
|
||||
}
|
||||
if (authToken && data.authToken !== authToken) {
|
||||
return res.status(401).json({ message: 'Unauthorized' })
|
||||
}
|
||||
@@ -112,7 +115,7 @@ app.post('/cloudflare', async (req, res) => {
|
||||
}
|
||||
|
||||
let cacheKey, cached
|
||||
if (CACHE_ENABLED && data.mode === "iuam") {
|
||||
if (CACHE_ENABLED && data.mode === "iuam" && !data.include_html) {
|
||||
|
||||
cacheKey = JSON.stringify(data)
|
||||
cached = readCache(cacheKey)
|
||||
@@ -150,7 +153,7 @@ app.post('/cloudflare', async (req, res) => {
|
||||
.then(r => ({ ...r }))
|
||||
.catch(err => ({ code: 500, message: err.message }))
|
||||
|
||||
if (CACHE_ENABLED && (!result.code || result.code === 200)) {
|
||||
if (CACHE_ENABLED && !data.include_html && (!result.code || result.code === 200)) {
|
||||
writeCache(cacheKey, result)
|
||||
}
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user