AWS Bot control on http Library

In my project , I need to retrieve client ip address and browser info from api hit. For that my code is as follows

from fastapi import FastAPI
from starlette.requests import Request
import httpagentparser
app = FastAPI()


@app.get("/test")
def read_root(request: Request):
    client_host = request.client.host
    browser = request.headers['user-agent'] 
   
    browser_parser = httpagentparser.simple_detect(browser)
    # 0 - Device OS, 1 - Browser (Safari, chrome )
    browser_name = browser_parser[0] + " , " + browser_parser[1]
    return {"client_host": client_host, "browser_name ": browser_name }

This is launched at AWS Lambda and when I make a request API , request goes throgh APIgateway with AWS Lambda as backend integration. The request is successful.

But when I enable AWS bot control , then all my requests are blocked by Bot control enabled under AWS WAF.While I look Sample of Bot categories , it is written requests blocked due to http_library.

How can I solved this problem to make my request successful after enabling AWS bot control?



from Recent Questions - Stack Overflow https://ift.tt/wplXuhU
https://ift.tt/b0mGdeN

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation