mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-19 17:36:09 -05:00
fix: load env variables
This commit is contained in:
@@ -14,7 +14,12 @@ export default async function RootLayout({
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
console.log('Environment variables:');
|
||||
console.log('NEXT_PUBLIC_URL:', process.env.NEXT_PUBLIC_URL);
|
||||
console.log('NEXTAUTH_URL:', process.env.NEXTAUTH_URL);
|
||||
|
||||
const session = await getSession()
|
||||
console.log('Session:', session);
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
|
||||
21
src/auth.ts
21
src/auth.ts
@@ -10,6 +10,21 @@ declare module "next-auth" {
|
||||
}
|
||||
}
|
||||
|
||||
function getDomainFromUrl(urlString: string | undefined): string {
|
||||
if (!urlString) {
|
||||
console.warn('NEXTAUTH_URL is not set, using localhost:3000 as fallback');
|
||||
return 'localhost:3000';
|
||||
}
|
||||
try {
|
||||
const url = new URL(urlString);
|
||||
return url.hostname;
|
||||
} catch (error) {
|
||||
console.error('Invalid NEXTAUTH_URL:', urlString, error);
|
||||
console.warn('Using localhost:3000 as fallback');
|
||||
return 'localhost:3000';
|
||||
}
|
||||
}
|
||||
|
||||
export const authOptions: AuthOptions = {
|
||||
// Configure one or more authentication providers
|
||||
providers: [
|
||||
@@ -47,11 +62,13 @@ export const authOptions: AuthOptions = {
|
||||
ethereum: viemConnector(),
|
||||
});
|
||||
|
||||
const domain = getDomainFromUrl(process.env.NEXTAUTH_URL);
|
||||
console.log('Using domain for auth:', domain);
|
||||
|
||||
const verifyResponse = await appClient.verifySignInMessage({
|
||||
message: credentials?.message as string,
|
||||
signature: credentials?.signature as `0x${string}`,
|
||||
// question: what domain should this be?
|
||||
domain: new URL(process.env.NEXTAUTH_URL ?? '').hostname,
|
||||
domain,
|
||||
nonce: csrfToken,
|
||||
});
|
||||
const { success, fid } = verifyResponse;
|
||||
|
||||
Reference in New Issue
Block a user