简体   繁体   中英

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. I'm now developing the frontend from which I'm trying to send a simple get request to the AWS python server. Trying different solutions to the CORS header issue I added:

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). I decided to instead use the 'django-cors-headers' middleware so that it would work both locally and on AWS. But now it wont work on AWS since it registers multiple Access-Control-Allow-Origin domains.

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.

Could someone help me find a solution?

I had the same issue, to fix it, you need to add this on your django.config:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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