skip to Main Content

Hi I have following situation:

Backend: Loopback/nodejs service

Frontend: Angular >=2

And i wana perform login via facebook. But there is problem – when i sent below request by angular http provider:

GET https://www.facebook.com/v2.9/dialog/oauth?client_id=1234567890123456&redirect_uri=http://my-domain.com/#/login?type=fb

the request which actually go out from web browser is:

GET https://www.facebook.com/v2.9/dialog/oauth?client_id=1234567890123456&redirect_uri=http://my-domain.com/

So the browser or http provider cut off everything after hash ‘#’. I try to change this character to it’s escape sequence # = %23 but when facebook redirect to this site this code was not change to # so the server cannot find url my-domain.com/%23/login....

What to do?

2

Answers


  1. Chosen as BEST ANSWER

    I try to remove '#' from angular routing but after that, the backend have problem with links like my-domain.com/login because this link works only on angular application but not in node.js server - so server fail.

    So i found other solution - first - remove '#' from angular http request - so send following request to fb:

    GET https://www.facebook.com/v2.9/dialog/oauth?client_id=1234567890123456&redirect_uri=http://my-domain.com/login?type=fb
    

    And then in backend just implement redirection for one link:

    my-domain.com/login -> my-domain.com/#/login
    

    So in loopback nodejs server we redirect login without hash to login with hash and thats all - nothing more to change :)


  2. Just to note if someone comes here:

    as of August 2018, the # -> %23 trick works and Facebook correctly redirects the browser back to the wanted URL that actually includes #.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search