gpt4 book ai didi

python - Django CORS X-FirePHP 版本

转载 作者:太空宇宙 更新时间:2023-11-03 16:19:19 24 4
gpt4 key购买 nike

当我尝试访问端点时收到以下错误消息。

Request header field X-FirePHP-Version is not allowed by Access-Control-Allow-Headers in preflight response.

这就是我的 settings.py 文件的样子

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'api.apps.ApiConfig',
'django_server',
'corsheaders', # For Cross-Origin Resource Sharing
]

CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_CREDENTIALS = False

最佳答案

如果您在向启用 CORS 的服务器发出的请求中包含其他 header ,则应在 CORS_ALLOW_HEADERS django-cors 中指定这些 header 。环境。这应该可以解决这个问题,但我会仔细检查以确保这些 header 应该存在。

# In your project's settings.pyCORS_ALLOW_HEADERS = (    'x-requested-with',    'content-type',    'accept',    'origin',    'authorization',    'x-csrftoken',    'x-firephp-version',  # Added to default list)# more settings...

在底层,这只是在服务器响应上设置 Access-Control-Request-Headers header 。

关于python - Django CORS X-FirePHP 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38649170/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com