简体   繁体   English

AWS Elastic Beanstalk,不会使用“eb deploy”更新 django.config

[英]AWS Elastic Beanstalk, wont update django.config with "eb deploy"

I've deployed a API application to AWS Elastic Beanstalk written in python and django.我已经将一个 API 应用程序部署到了用 python 和 django 编写的 AWS Elastic Beanstalk。 I'm now developing the frontend from which I'm trying to send a simple get request to the AWS python server.我现在正在开发前端,我试图从中向 AWS python 服务器发送一个简单的 get 请求。 Trying different solutions to the CORS header issue I added:尝试针对我添加的 CORS 标头问题的不同解决方案:

files:
  "/etc/httpd/conf.d/cors.conf" :
    mode: "000644"
    owner: root
    group: root
    content: |
      <Location "/">
        Header set Access-Control-Allow-Origin: *
        Header set Access-Control-Allow-Methods: "POST, GET, PUT, DELETE, OPTIONS"
        Header add Access-Control-Allow-Headers: "Authorization, Content-Type, Accept"
        Header set Access-Control-Allow-Credentials: true

        SetOutputFilter DEFLATE
      </Location>

to the django.config file which made it work on AWS but not locally (the django.config file is located in .ebextensions file).到 django.config 文件,使其在 AWS 上运行但不能在本地运行(django.config 文件位于 .ebextensions 文件中)。 I decided to instead use the 'django-cors-headers' middleware so that it would work both locally and on AWS.我决定改用 'django-cors-headers' 中间件,这样它就可以在本地和 AWS 上工作。 But now it wont work on AWS since it registers multiple Access-Control-Allow-Origin domains.但现在它无法在 AWS 上运行,因为它注册了多个 Access-Control-Allow-Origin 域。

So after removing the above files: code from django.config the problem persisted so the reasonable problem would be that the header is added both by the middleware and by the django.config code which I'm not able to remove.因此,在删除上述文件后:django.config 中的代码问题仍然存在,因此合理的问题是标题是由中间件和我无法删除的 django.config 代码添加的。

Could someone help me find a solution?有人可以帮我找到解决方案吗?

I had the same issue, to fix it, you need to add this on your django.config:我遇到了同样的问题,要修复它,您需要在 django.config 中添加它:

container_commands:
  01_wsgipass:
    command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM