pip install django-cors-headers
- INSTALLED_APPS = (
- ...
- 'corsheaders',
- ...
- )
- MIDDLEWARE = [
- 'corsheaders.middleware.CorsMiddleware',
- ...
- ]
- # CORS
- CORS_ORIGIN_WHITELIST = (
- '127.0.0.1:8080',
- 'localhost:8080',
- 'www.meiduo.site:8080',
- 'api.meiduo.site:8000'
- )
- CORS_ALLOW_CREDENTIALS = True # 允许携带cookie