0

I am trying to create a reconnect to another site on my server.

Currently using $location.url('http://127.0.0.1/second'); to forward to the second site, but I need to set the Authorization Header to a custom variable.

I searched through the $http and $location documentation on docs.angularjs.org, but I wasn't able to find anything helpful.

scniro
  • 16,844
  • 8
  • 62
  • 106
Jannis Lehmann
  • 1,428
  • 3
  • 17
  • 31
  • has nothing to do with angular. There's no way to set headers for redirect other than basic auth in url – charlietfl May 11 '15 at 14:09
  • How can I do it else? I need to set the header and need a recreate. I don't want to pass it via a GET param – Jannis Lehmann May 11 '15 at 15:10
  • you can't , it's a request initiated by the browser itself, not by any code. Even using window.open you can't http://stackoverflow.com/questions/4325968/window-open-with-headers – charlietfl May 11 '15 at 15:13
  • One way to do this is with an nginx (or apache) proxy that allows access to the 2nd site (by either adding the header or bypassing it altogether based on referrer). But that begs the question what is the point of the custom Auth header if you are just bypassing it without asking the user for it? What is the value of the variable? Is it user supplied or some kind of token? – notbrain May 13 '15 at 00:13
  • It is a token. So nothing user supplied. – Jannis Lehmann May 13 '15 at 16:05

1 Answers1

1

Actually you can use $http;

$http({method: 'GET', url: 'http://127.0.0.1/second', headers: {
    'Authorization': 'Basic Key'}
});

For more INFO...

hurricane
  • 6,521
  • 2
  • 34
  • 44