-1

I have production server say ServerA in which I have deployed my angular application. I am deployed it in Tomcat . Now I have another server which is serving backend calls say ServerB now when my angular application running on ServerA makes calls to ServerB. It is giving CORS issue.

Please note:- I am using https protocol

Any Idea how to make such calls

Aniket
  • 310
  • 1
  • 4
  • 22

3 Answers3

0

Two options

  1. Use a proxy kind of servlet in Server A and have a communication b/w Server A and Server B See : Smiley's HTTP Proxy Servlet

or

  1. Have a CORSFilter in Server B which accepts requests from Server A angular application See : Access-Control-Allow-Origin
vels4j
  • 11,208
  • 5
  • 38
  • 63
0

ServerB needs to set response headers. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin

MoxxiManagarm
  • 8,735
  • 3
  • 14
  • 43
0

The server needs to handle the origin. Here ServerB should accept request from ServerA and should sent header response as:-

Access-Control-Allow-Origin: http://ServerA.com Access-Control-Allow-Credentials: true Access-Control-Expose-Headers: FooBar Content-Type: text/html; charset=utf-8

I recommend to go this blog https://www.html5rocks.com/en/tutorials/cors/ for better understanding. This explains clearly on handling simple and not so simple requests.

Sanket
  • 612
  • 5
  • 23