【发布时间】:2019-08-21 21:36:47
【问题描述】:
作为一个学术项目,我们使用 Amazon S3(适用于 Angular)和 Apache Server(适用于 Django)托管我们的 Web 应用程序。我们已将两个站点设为 https(用于前端和后端)。我们可以使用 ng serve 在本地主机上成功访问后端。但是,对于生产站点,它总是给我们一个混合内容错误(尝试为我们的后端连接 HTTP)。但我们实际上将 https 放在了我们的 Angular 代码中。对此有什么建议吗?
附上我们的前端代码
export class AuthenticationService {
private ip: string = 'https://sunrise.99jhs.com';
authenticate(username: string, password: string) {
const headers = new HttpHeaders();
headers.append('Access-Control-Allow-Origin', '*');
return this.http.post<any>(this.ip + '/api-token-auth/', {username, password}, {headers});
}
附上错误提示
Mixed Content: The page at 'https://sunrise.4jhs.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://sunrise.99jhs.com/api-token-auth'. This request has been blocked; the content must be served over HTTPS.
我们使用构建角度代码
ng build --prod
【问题讨论】:
标签: django angular apache amazon-s3