我正在使用 Hostinger VPS 云主机来托管 django 后端,在托管 IP 地址和端口但不在域中时一切正常?

问题描述 投票:0回答:1

托管问题 Its showing like this , But in IP address its is working fine all the images are fetching from backend... See this also coming like this but its working in IP address with port its working fine ,while in domain its not working or posting the  form

如果我检查托管方法,它工作正常,但在我的域中工作不佳,我是否必须更改服务器配置文件中的某些内容

django cross-domain hosting ip-address cross-domain-proxy
1个回答
0
投票

我认为您忘记在 CSRF_TRUSTED_ORIGINS 中添加您的域。

只需在设置文件中的 CSRF_TRUSTED_ORIGINS 中添加域,如下所示。

适用于 django 4 及以上版本

CSRF_TRUSTED_ORIGINS = ['https://yourdomain.com']

对于django 3及以下版本,无需提及scheme

CSRF_TRUSTED_ORIGINS = ['yourdomain.com']

阅读此处获取更多详细信息:CSRF_TRUSTED_ORIGINS

© www.soinside.com 2019 - 2024. All rights reserved.