Skip to content

Commit

Permalink
fix: add dynamic url sign message
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Nov 20, 2024
1 parent a927e9f commit 3fec75a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src/components/SignInDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ const SignInWithEthereum = () => {
const { nonce } = await fetch(`${env.NEXT_PUBLIC_API}/auth/siwe/nonce`)
.then((res) => res.json())
.then((data) => z.object({ nonce: z.string() }).parse(data));

const urlHostname = `${new URL(env.NEXT_PUBLIC_URL).hostname}:${window.location.port}`;
console.log(urlHostname);
const message = createSiweMessage({
address: address!,

Check warning on line 93 in src/components/SignInDialog.tsx

View workflow job for this annotation

GitHub Actions / quality-assurance

lint/style/noNonNullAssertion

Forbidden non-null assertion.
chainId: 1,
domain: "localhost:3000",
domain: urlHostname,
nonce,
uri: "localhost:3000",
uri: urlHostname,
version: "1",
});

Expand Down
12 changes: 2 additions & 10 deletions src/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,16 @@ import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
server: {
API: z.string(),
URL: z.string(),
},
server: {},
client: {
NEXT_PUBLIC_API: z.string(),
NEXT_PUBLIC_URL: z.string(),
},
runtimeEnv: {
API: process.env.NEXT_PUBLIC_API,
URL:
process.env.NODE_ENV === "production"
? process.env.NEXT_PUBLIC_URL
: "http://127.0.0.1",
NEXT_PUBLIC_API: process.env.NEXT_PUBLIC_API,
NEXT_PUBLIC_URL:
process.env.NODE_ENV === "production"
? process.env.NEXT_PUBLIC_URL
: "http://127.0.0.1",
: "http://localhost",
},
});

0 comments on commit 3fec75a

Please sign in to comment.