简体   繁体   English

在 flask 应用程序中出现 403 禁止错误

[英]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.

相关问题 将 Laravel 应用程序部署到 AWS Elastic Beanstalk 时出现“403 Forbidden”错误 - Getting a '403 Forbidden' error on deploying a Laravel application to AWS Elastic Beanstalk 通过浏览器访问网站时出现403(禁止访问)错误 - getting 403(Access Forbidden) error while accessing the site through browser 通过ansible访问AWS时遇到403禁止错误 - Getting a 403 forbidden error on accessing AWS through ansible AWS WAF 在尝试上传图像时出现 403 禁止错误 - AWS WAF Getting 403 forbidden error while trying to upload an image 错误代码:403将应用程序提交到无服务器应用程序存储库时被禁止 - Error Code: 403 Forbidden when submitting app to serverless application repository 带有SSL的Elastic Beanstalk上的烧瓶显示403禁止 - Flask on Elastic Beanstalk with SSL gives 403 Forbidden 使用AWS开发工具包从AWS Elastic Search获取索引时出现403禁止错误 - 403 forbidden error while getting indexes from AWS Elastic search using AWS SDK 从自定义域访问 static 站点时出现 403(禁止)错误 - Getting 403 (Forbidden) error when accessing static site from custom domain 尝试使用 AWS SDK 从 Java 应用程序连接 SQS 时出现 403 禁止错误 - 403 forbidden error while trying to connect SQS from Java application using AWS SDK 403禁止使用没有SSL的AWS Beanstalk Flask静态文件 - 403 forbidden for AWS Beanstalk Flask static files without SSL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM