美文网首页django-rest-framework开发
django-rest-framework(实战篇)——设置服务

django-rest-framework(实战篇)——设置服务

作者: Ccccolin_aha | 来源:发表于2018-04-09 15:49 被阅读21次

django-cors-headers

Django app for handling the server headers required for Cross-Origin Resource Sharing (CORS)

pip install django-cors-headers

INSTALLED_APPS = (
    ...
    'corsheaders',
    ...
)

然后添加我们的middleware,要放的尽可能靠前,在csrfview之前。
设置参数为True
CORS_ORIGIN_ALLOW_ALL = True

相关文章

网友评论

    本文标题:django-rest-framework(实战篇)——设置服务

    本文链接:https://www.haomeiwen.com/subject/vpyihftx.html