簡體   English   中英

如何通過托管在https上的reactjs-app對HTTP上托管的rest-api的吸引力解決錯誤

[英]How to solve error with appeal to my rest-api hosted on http from my reactjs-app hosted on https

我的reactjs中的提取函數出現錯誤:當我從托管在http上的rest-api(ASP.NET)請求數據時,托管在Firebase(https)上的我的應用拋出錯誤:

混合內容:“ https:// [my-domain] .firebaseapp.com / ”上的頁面已通過HTTPS加載,但請求了不安全的資源
'http:// :***** / filter1 / filter2'。 該請求已被阻止; 內容必須通過HTTPS提供。

其余部分由ASP.NET托管在Linux上。 我們已經嘗試過通過.NET CORE選項制作SSL證書。

fetch(`http://host-ip:port/filter1/filter2`, {
                        method      : 'GET',
                        mode        : 'cors',
                        credentials : 'same-origin',
                    }).then(res  => res.json())
                        .then(json => {
                            this.setState(
                                { 
                                    //some operations
                                }
                            )
                    })

可以通過安裝SSL證書進行修復,但我們沒有特殊的域名(僅ip地址)。 是否可以通過不對域和證書進行任何狡猾的操作來解決? 我們可以將其保留在我們的IP上而無需過渡到域嗎?

是啊

您應該在https使用Rest-Api 將有效的SSL證書安裝到Rest-Api Server並正確配置。

您可以使用添加DNS A Record並為該域安裝SSL來為rest-api創建一個sub-domain域。

我在用

APP:https: //myapp.com (https)

API:(my-rest-api-aws-ip)(http)

IN DNS(記錄)

api.myapp.com >>>>(my-rest-api-aws-ip)

然后,我使用加密功能api.myapp.com安裝了免費的SSL證書

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM