This repo demonstrates various methods for navigating a user to a new window without triggering a popup blocker, particularly when you need to wait for an async operation like requesting an auth token.
Read the blog post for more details.
Open this example on CodeSandbox.
admin/index.tsx
- DefinesLoginWithGet
andLoginWithPost
components, which handle opening a new window and making the auth token request.admin/login-as.tsx
- For the GET request, this file acts as a placeholder for your user. For the POST request, this also handles submitting the POST request once the auth token has been fetched.app/api/login.ts
- Handles both GET and POST requests to log into the "main" app.