Kevin Z.
Kevin Z.

Reputation: 85

Localhost being prepended to Fetch request

I'm using a https url and for whatever reason fetch is adding localhost:300 to the start of the url. When I check the url that it's calling I get this: http://localhost:3000/%E2%80%8Bhttps://www... anybody know why?

  // load API 
  componentDidMount() {
    fetch('https://www.URL.com/api/route').then(res => {
      return res.json()
    }).then(data => {
      this.setState({
        orders : data
      })
    })
  }

Upvotes: 3

Views: 1472

Answers (2)

Milan Zivkovic
Milan Zivkovic

Reputation: 9

I had a similar problem in react application I was building. Mistyped URL was my mistake.

Upvotes: -1

ziggahunhow
ziggahunhow

Reputation: 79

I encountered the same problem, and it was because I had a whitespace character in the beginning of the url before "https...". Perhaps you had a similar problem so fetch read the url as a relative path instead.

Upvotes: 2

Related Questions