📌  相关文章
📜  我如何在 django rest 框架中动态填充到 CORS_ALLOWED_ORIGINS - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:37.040000             🧑  作者: Mango

代码示例1
django-cors-headers has a signal that allows you to decide whether or not to allow the request to pass. The docs show exactly your use case.

Note that CORS_ORIGIN_WHITELIST is also checked by the cors middleware (the signal response doesn't replace the white list), so you can have both: a static whitelist + a dynamic whitelist that depends on the request. You don't need to check the static whitelist in your signal handler.
                                                                        
                                                                        https://github.com/adamchainz/django-cors-headers