Bugfix/IP API (#2283)

fix ip API
This commit is contained in:
Henry Heng
2024-04-29 22:19:31 +01:00
committed by GitHub
parent b7eb876b39
commit 5775947586
4 changed files with 10 additions and 42 deletions
@@ -1,26 +0,0 @@
import { Request, Response, NextFunction } from 'express'
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
import { StatusCodes } from 'http-status-codes'
// Configure number of proxies in Host Environment
const configureProxyNrInHostEnv = async (req: Request, res: Response, next: NextFunction) => {
try {
if (typeof req.ip === 'undefined' || req.ip) {
throw new InternalFlowiseError(
StatusCodes.PRECONDITION_FAILED,
`Error: ipController.configureProxyNrInHostEnv - ip not provided!`
)
}
const apiResponse = {
ip: req.ip,
msg: `Check returned IP address in the response. If it matches your current IP address ( which you can get by going to http://ip.nfriedly.com/ or https://api.ipify.org/ ), then the number of proxies is correct and the rate limiter should now work correctly. If not, increase the number of proxies by 1 and restart Cloud-Hosted Flowise until the IP address matches your own. Visit https://docs.flowiseai.com/configuration/rate-limit#cloud-hosted-rate-limit-setup-guide for more information.`
}
return res.send(apiResponse)
} catch (error) {
next(error)
}
}
export default {
configureProxyNrInHostEnv
}