Mojtaba
Mojtaba

Reputation: 874

Network Request Failed in ReactNative

The ReactNative's fetch method causes Network Request Failed error in requesting API URL or any other resources from jordanpizza.ir. I made a fork(https://codesandbox.io/s/5vwyq4wmnp) of react-native-web project's sandbox with this addition code at App.js:

componentDidMount() {
    fetch("https://jordanpizza.ir/test.json").then(response => {
      console.log(response);
    });
  }

This sandbox reproduces my problem.

Note: All resources are accessible from Postman or direct request in browser.

Upvotes: 0

Views: 592

Answers (2)

Charky
Charky

Reputation: 56

Try too use this. Cors Maybe that's is your problem

Upvotes: 1

Mojtaba
Mojtaba

Reputation: 874

The problem had two aspects:

  1. CORS error that solved by the @mikheevm solution.

  2. DDoS protection on layer 7 provided by ArvanCloud. It blocked our requests and caused 307 redirections to be repeated, which ended when the request was canceled. This problem was also solved by clinging to the basic protection.

Upvotes: 0

Related Questions