-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

0

3 Answers 3

0

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.