Get token before opening

Summary:
Get the authentication token before an open as either browser or PWA.

There could be cases whereas the PWA gets launched first before the token is exported to the manifest and thus it makes it not possible to connect on a first launch.

Reviewed By: antonk52

Differential Revision: D50004992

fbshipit-source-id: d58b7a75dcb9aaf7fadd3e3c3a773581441f9d92
This commit is contained in:
Lorenzo Blasa
2023-10-06 03:26:14 -07:00
committed by Facebook GitHub Bot
parent f11052cffd
commit 33962d4fa4

View File

@@ -292,15 +292,17 @@ async function start() {
async function launch() {
console.info('[flipper-server] Launch UI');
const token = await getAuthToken();
console.info(
`[flipper-server] Get authentication token: ${token?.length != 0}`,
);
if (!argv.open) {
return;
}
const openInBrowser = async () => {
console.info('[flipper-server] Open in browser');
const token = await getAuthToken();
console.info('[flipper-server] Token is available:', token !== undefined);
const searchParams = new URLSearchParams({token: token ?? ''});
const url = new URL(`http://localhost:${argv.port}?${searchParams}`);