[英]Getting 403 forbidden error in flask application
I am running a flask application in AWS fargate.我正在 AWS fargate 中运行 flask 应用程序。 In the app, I call a POST api which internally needs to call a public endpoint to collect some data using requests.get() method.在应用程序中,我调用了 POST api,它在内部需要调用公共端点以使用 requests.get() 方法收集一些数据。
@app.route("/findByPin", methods=["POST"]
def find_by_pin():
pincode = request.form['pincode']
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
url = [SOME_URL]?pincode=pincode
requests.get(url, headers=headers)
The error that I am facing is that the API call to the public endpoint is returning 403 status code in response.我面临的错误是对公共端点的 API 调用返回 403 状态代码作为响应。 While if I run the application in my localhost, it works fine.如果我在本地主机中运行应用程序,它可以正常工作。
Since this is an open endpoint, I don't understand why it would return a 403 Forbidden error.由于这是一个开放端点,我不明白为什么它会返回 403 Forbidden 错误。
Edit: This is the error message: Request blocked. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
编辑:这是错误消息: Request blocked. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
Request blocked. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
The 403 error comes from the public endpoint you are calling, they might be blocking AWS IPs to prevent trafic overload from bots. 403 错误来自您调用的公共端点,它们可能会阻止 AWS IP 以防止来自机器人的流量过载。 You can tunnel your request trough a VPN running on a non AWS instance.您可以通过在非 AWS 实例上运行的 VPN 传输您的请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.