简体   繁体   中英

Why does my application break when I try to use corsheaders?

I have a client with a django web application which pulls information from a different web application and displays it on a web page.

The web application suddenly stopped working and the following message appeared in the server's supervisorctl:

https://imgur.com/oKz6rTJ

I didn't have much time, so I traced the error to the CorsHeaders middleware and commented it out from the website's settings.py while I work on a long term solution. To save people time researching, Cors is a middleware which allows web browsers to access your server even if it is in a different domain than the web page. (aka what the client uses to upload their data from one webapp to another)

This image outlines what I commented out: https://imgur.com/a/tEBiYGU

As mentioned, commenting out that middleware prevented it from loading any new data but the current graphs had no issues being displayed. This confirmed my suspicion that corsheaders was the sole problem.

Now I had a bit more time to research the issue at home and realized that the crux of the issue is the fact that the middleware is what calls on the apps import:

https://imgur.com/a/0812jFJ

Now I will admit that while I have some python experience, I have no experience with Django and I have no idea how its apps work or what that import is doing. I ran

find /path/to/django/ -name "apps"

and also,

find /path/to/django/ -name "apps.py"

and I got 0 hits. I'm not even sure that this django.apps exists in Django 1.3.1 which is what this client is running along with python 2.6.6

I have already considered an upgrade but there are loads of other applications running on the server that a python or django upgrade is out of the question. Is there any way to resolve this?

No resolution found and the server is being decommissioned. Good riddance :)

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