0

We are having two applications. One is written running on salesforce (App A and other app (App B) is using angularJS for UI.

When a user performs a certain actions in App A, App B has to be opened in a new tab. In this case, certain parameters have to be passed to App B from App A.

As App A and App B are running in different domain we can't use cookies to share the data.

So we wanted to pass it as a http header. Is it possible to read the http header in angular JS?

Please note that this different from AngularJS - accessing http headers. That was related when we access a http from angular JS. But we want to read the http headers passed to our angularJS application.

How can we read the HTTP headers sent to an angular JS application? Or is there any better approach to solve this issue?

Community
  • 1
  • 1
sag
  • 5,333
  • 8
  • 54
  • 91

2 Answers2

2

You can access headers from $http or from $resource but depends on what you are trying to do. If passing the state/data then it might not be possible.

pass as query string in the App B URL and open in new window/tab. Login information might not persist in second domain if you are not using Auth2/Auth domain authorization method and not sending data using get method with request data when opening in new tab or window.

Gary
  • 2,293
  • 2
  • 25
  • 47
  • 1
    Just wanted to add as a confirmation - You `CAN` access http REQUEST headers from AngularJS. Read about `config` of $http or $resource. However, you cannot manipulate RESPONSE headers. The passing of data through `GET` method as query string might be needed if you are going to trigger a third party link in a new tab (which will not be able to access session details from previous site). You have to work around the state/data that is being passed, if sent from Client side application. – Gary Dec 09 '15 at 12:59
1

You need the assistance from server side, you don't have the access to page headers in JS, and it isn't Angular issue.

You can try cross-domain localStorage with this package. It also has Angular module bundled.

Estus Flask
  • 206,104
  • 70
  • 425
  • 565