I'm having trouble getting my local dev server of an Angular app to connect to my local PHP server of my api.
It's pretty much exactly the same problem expressed in this question:
ECONNREFUSED for proxy request from localhost to another localhost
Imagine the following:
/api (PHP API source)
/myapp (angular app)
I run the following in /api:
php -S localhost:8000
Then, in /myapp, I run the following:
ng serve
In my app, I have the following proxy.conf.json:
{
"/api.php/v1/User": {
"target": "http://localhost:8000",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
/api/api.php is the main entrypoint for all api calls. I then use the rest of the address to identify the correct call, prepended by /v1/User.
I've confirmed that the API runs fine by it's self. But when accessing the app in the browser the following errors occur:
[HPM] POST /api.php/v1/User/Auth -> http://localhost:8000
[HPM] Error occurred while trying to proxy request /api.php/v1/User/Auth from localhost:4200 to http://localhost:8000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
No errors are received on the PHP server side, which leads me to believe the proxy isn't even talking to the PHP server.