I just started with a Angular 4 & Spring Boot web application. I'm trying to call a REST path:
ngOnInit(): void {
// Make the HTTP request:
this.http.get('/greeting').subscribe(data => {
// Read the result field from the JSON response.
this.results = data['results'];
});
}
But the resulting URL is GET http://localhost:4200/greeting 404 (Not Found). I've researched this topic and a lot of advice was to add a proxy file for NPM so it changes the routes.
"start": "ng serve --proxy-config proxy.conf.json",
And the proxy.conf.json file:
{
"/api": {
"target": "http://localhost:8080",
"secure": false
}
}
When I run npm run start I get the following message:
[email protected] start
C:\Users\alucardu\Documents\projects\movieseat\frontend\src\main\frontend> ng serve --proxy-config proxy.conf.jsonLive Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
So the proxy file is loaded but it has no effect. Am I using outdated information or just doing something wrong?
getcall a full URL ?http://localhost:4200/greetingso it's doing the request from the NPM server./apito/*in yourproxy.conf.json