hostname for localhost

This commit is contained in:
Max Peintner
2024-10-28 16:48:57 +01:00
parent 3566ae91e1
commit c8fd63a169
2 changed files with 11 additions and 4 deletions

View File

@@ -37,12 +37,18 @@ export async function registerPasskeyLink(
sessionToken: sessionCookie.token,
});
const domain = headers().get("host");
const host = headers().get("host");
if (!domain) {
if (!host) {
throw new Error("Could not get domain");
}
const [hostname, port] = host.split(":");
if (!hostname) {
throw new Error("Could not get hostname");
}
const userId = session?.session?.factors?.user?.id;
if (!userId) {
@@ -60,7 +66,7 @@ export async function registerPasskeyLink(
throw new Error("Missing code in response");
}
return registerPasskey(userId, registerLink.code, domain);
return registerPasskey(userId, registerLink.code, hostname);
}
export async function verifyPasskey(command: VerifyPasskeyCommand) {

View File

@@ -75,7 +75,8 @@ export async function updateSession(options: UpdateSessionCommand) {
challenges.webAuthN &&
!challenges.webAuthN.domain
) {
challenges.webAuthN.domain = host;
const [hostname, port] = host.split(":");
challenges.webAuthN.domain = hostname;
}
const recent = await sessionPromise;