How to request PHP and BD files on the same server created by the React-app

0

I'm learning how to use Framework React. In the submitting part of form data, and retrieving this data, I am using ajax with the jQuery function.

componentDidMount() {

    $.ajax({
      url:"http://localhost:80/contatos/dados-json.php",
      dataType:'json',
      success:function(clientes){
        this.setState({lista:clientes});
      }.bind(this)
    });
}

But this URL to whom I am requesting is from another server that is local to my machine (a Xampp server).

Translating, there are two Local Servers on the same machine

If you look like this:

  • React is - localhost: 3000 (npm create-react-app)
  • PHP and BD files - localhost: 80 (Xampp)
  • The problem with this is that I get cross-server requests, and it ends up giving me more problems to work.

    I would like to know how to put PHP and BD files on the same React server?

        
    asked by anonymous 10.01.2018 / 21:32

    0 answers