The HTTP API associated with the custom domain name cannot be invoked via fetch.

0

The HTTP API associated with Lambda was successfully connected to Custom domain. So I connected to the xxx.mydomain.com/vi/direct path. It was then called normally when opened in Chrome tab. However, the error "Failed to load resource: {myApiUrl} net::ERR_NAME_NOT_RESOLVED" occurs when trying to invoke via fetch in the React project. What else do you need?

const callDirectUrlAPI = async() => {
    const header = new Headers();
    try {
        const result = await fetch("api.****.com/vi/test/direct",{
            method : "GET",
        })
        console.log(await result.text())
    } catch (error) {
        console.log(error)     
    }
}

The above code is the function I used to call the API.

已提問 2 年前檢視次數 331 次
1 個回答
1

Maybe you need to specify https:// in front of the domain?

profile pictureAWS
專家
Uri
已回答 2 年前
  • Yes, I replaced it with another letter to prevent API abuse.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南