-
Notifications
You must be signed in to change notification settings - Fork 123
[CON-667] Update Solana Staking UI #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| const response = await fetch(url); | ||
| const apiKey = process.env.NEXT_PUBLIC_JUPITER_API_KEY; | ||
| if (!apiKey) { | ||
| throw new Error("JUPITER_API_KEY is not set in environment variables"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message references wrong environment variable name
The error message thrown when the API key is missing says "JUPITER_API_KEY is not set in environment variables" but the actual environment variable being checked is NEXT_PUBLIC_JUPITER_API_KEY. This misleading message would cause developers to set the wrong variable name when troubleshooting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems likeNEXT_PUBLIC prefix a way for Next to warn us it's going to expose the variable - we wouldn't want to do that, see https://nextjs.org/docs/app/guides/environment-variables
Can we just use process.env.JUPITER_API_KEY and make this server-only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change after this commit already. It is server-only and I moved the Price API call to api:
const apiKey = process.env.JUPITER_API_KEY;
if (!apiKey) {
return NextResponse.json(
{ error: "JUPITER_API_KEY is not set in environment variables" },
{ status: 500 }
);
}
mikemaccana
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a security issue with the API key (see the comment) but looks good once that's resolved. 👍
| const url = new URL(JUPITER_PRICE_ENDPOINT); | ||
| url.searchParams.set("ids", WRAPPED_SOL_ADDRESS); | ||
|
|
||
| const apiKey = process.env.JUPITER_API_KEY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we throw earlier (ie, as soon as the server starts) if the environment variable isn't set, rather than waiting for an incoming GET?
| const response = await fetch(url); | ||
| const apiKey = process.env.NEXT_PUBLIC_JUPITER_API_KEY; | ||
| if (!apiKey) { | ||
| throw new Error("JUPITER_API_KEY is not set in environment variables"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems likeNEXT_PUBLIC prefix a way for Next to warn us it's going to expose the variable - we wouldn't want to do that, see https://nextjs.org/docs/app/guides/environment-variables
Can we just use process.env.JUPITER_API_KEY and make this server-only?
NEXT_PUBLIC_JUPITER_API_KEYto .env.exampleNote
Introduces a server-side price proxy and rebrands UI copy/assets.
GET /api/pricethat proxies Jupiter Price API v3 withx-api-keyfromJUPITER_API_KEY; returns{[address]: {usdPrice,...}}utils/solana/price.tsto v3 schema; UI (StakingForm) now polls/api/priceand readsusdPricefor SOL→USDJUPITER_API_KEYto.env.example; refine.gitignoreto ignore.env.*but keep.env.examplepublic/quicknode.svgsuppressHydrationWarningin layout, README instructions; patch dependency updates (Next, ESLint, Tailwind)Written by Cursor Bugbot for commit 0be11d7. This will update automatically on new commits. Configure here.