I'm building a React application that I started with create-react-app. In their documentation, they describe using a proxy server for API calls during development. I want to use this for when I make requests to my MAMP server for php files. However, the requests aren't being proxied to the assigned, it's still the webpack dev server serving it.
The create react app documentation says to put a line into the package.json file to set up the proxy. I've put "proxy": "http://localhost" in it (the MAMP server is running on port 80). The php file I'm trying to serve is in an "api" folder in the same directory as index.html
here's the request:
$.ajax({
url: "/api/test.php"
success: response=>{
console.log(response);
}
});
and test.php simply says: print("success")
But the console is reading:
<?php
print("success")
?>
which means it's the dev server, not the apache server that's serving the file. How can I fix this?