I've built a backend using Loopback with passport auth. It requires that I first visit http://localhost:3001/auth/github, which redirects to GitHub, which either displays a login page, or redirects back to my app on port 3001.
Now I'm building a ReactJS frontend on :3000. It's supposed to send AJAX calls to the backend appending the auth token as a query string parameter. I've added port forwarding to the client's package.json
, so all AJAX calls are handled correctly.
What I can't figure is how to get the auth token (received as a cookie from http://localhost:3001/auth/github/callback
) to the client side. While my AJAX calls are proxied correctly, when I navigate to /auth/github, I'm still on the React-generated page, and my :3001 endpoint isn't hit. If I go to :3001/auth/github, I'm not getting my auth_token cookie by my frontend code.
In other words, I have two problems:
1. How to navigate to my backend's auth page (http://localhost:3001/auth/github
) from the frontend?
2. How to get the cookie obtained in #1 to my frontend so that it could be used in the subsequent queries?
As I'm building a demo, I only need a quick and dirty solution that Just Works, but I'm willing to consider other ideas like opening a popup window and/or an IFrame.