1

I'm developing an application which has UI from Angular2 and back-end as a rest api which is done on Spring-boot.

When I access the URL to get the list of users, it doesn't fetch all the users. When I check the browser console I get the following error:

Failed to load http://localhost:8080/api/user/getAll: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

Any input will be appreciated.

Sibiraj
  • 4,486
  • 7
  • 33
  • 57
Deepak Jain
  • 305
  • 1
  • 3
  • 19

1 Answers1

1

If the frontend (Angular2) and backend (Boot) live on two different domains a solution would be to enable cors on the backend. Read here: https://docs.spring.io/spring/docs/4.2.x/spring-framework-reference/html/cors.html and here https://spring.io/guides/gs/rest-service-cors/

Fabio Maffioletti
  • 820
  • 1
  • 8
  • 17