My project utilizes Spring on the back-end and Angular2 on the front-end. In the webapp folder of my Spring project, there is a JSON file that I am attempting to access from Angular.
I can successfully access the file by directly typing "http://localhost:8080/project1/test.json"
However, when trying to access the same link from Angular, I encounter an error message stating "no access control allow origin header"
Here is a snippet of my Angular code: 1. Function getJson() defined in service.ts:
getJson(){
return this.http.get('http://localhost:8080/project1/test.json')
.map((response:Response) => response.json());
}
Calling getJson():
results=[];
this._manoService.getJson().subscribe(resJsonData => this.results = resJsonData);
I have created proxy.conf.json with the following configuration:
{
"/project1": {
"target": "http://localhost:8080",
"secure": false
}
}
In addition, I have added "start": "ng serve --proxy-config proxy.conf.json", to package.json
Despite these changes, I continue to face the same issue. Am I missing something here?