Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function getCallbackUrl(port?: number): string {
if (typeof port === "undefined") {
return "urn:ietf:wg:oauth:2.0:oob";
}
return `http://localhost:${port}`;
return `http://127.0.0.1:${port}`;
}

function queryParamString(args: { [key: string]: string | undefined }) {
Expand Down Expand Up @@ -632,14 +632,30 @@ async function loginWithLocalhost<ResultType>(
return;
});

server.listen(port, () => {
server.listen(port, "127.0.0.1", () => {
logger.info();
logger.info("Visit this URL on this device to log in:");
logger.info(clc.bold(clc.underline(authUrl)));
logger.info();
logger.info("Waiting for authentication...");

open(authUrl);

const timeoutId = setTimeout(() => {
if (server.listening) {
logger.info();
logger.info(
"Having trouble? Try " +
clc.bold("firebase login --no-localhost") +
" or " +
clc.bold("firebase login:ci"),
);
}
}, 30_000);

server.on("close", () => {
clearTimeout(timeoutId);
});
});

server.on("error", (err) => {
Expand Down