-
Notifications
You must be signed in to change notification settings - Fork 118
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
fix: Paymaster Proxy URL #513
Conversation
f1fe759
to
e5bcfe6
Compare
const defaultUrl = isLocalEnv ? paymasterURL : `${document.location.origin}/api/paymaster-proxy`; | ||
// Target the Paymaster directly without a proxy if running on localhost. | ||
// Use the Paymaster Proxy when deployed. | ||
const isLocalEnv = process.env.NEXT_PUBLIC_VERCEL_ENV === undefined; |
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.
What's wrong with isLocal
? should we fix that?
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.
isLocal
wasn't working for me. It was always returning that the application was running locally, even when deployed.
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 think that we can just take advantage of the Vercel System Environment Variable
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.
It actually looked like the issue was with getCurrentEnvironment - a function that isLocal
relies on.
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.
My advice here is, to make sure isLocal()
works well. And just use that everywhere.
And avoid doing side solution.
In a few words, improve what we have, and avoid create N+1 solution for the same problem.
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.
Makes sense! I updated getCurrentEnvironment to have the NEXT_PUBLIC prefix and it now works. I've tested in local and dev!
99e9a13
to
ea9bd4f
Compare
3fd11d3
to
c00c673
Compare
c00c673
to
e6ab8fd
Compare
What changed? Why?
We are checking if process.env.NEXT_PUBLIC_VERCEL_ENV is undefined which means that we are on local. Therefore, we will hit our Paymaster directly.
When deployed we are using the System Environment Variable
NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL
.Notes to reviewers
How has it been tested?
Tested locally and in Vercel Dev.