W
Wasp-lang2w ago
Wix

Customer portal

ZodError: [ { "code": "invalid_type", "expected": "string", "received": "undefined", "path": [], "message": "Required" } ] I am getting this error when clicking manage supscription only in production however I have added REACT_APP_STRIPE_CUSTOMER_PORTAL and STRIPE_CUSTOMER_PORTAL_URL to my erver secrets on fly and REACT_APP_STRIPE_CUSTOMER_PORTAL to my client secrets
5 Replies
kapa.ai
kapa.ai2w ago
Hi @Wix. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message you're seeing is from the Zod validation library, indicating that an expected string value is undefined. This suggests that the environment variable REACT_APP_STRIPE_CUSTOMER_PORTAL is not being correctly set or accessed in your production environment. In Wasp, environment variables are used to configure projects based on the context in which they run. For client-side environment variables, they are embedded into the client code during the build and shipping process. To enable Wasp to pick them up, client environment variables must be prefixed with REACT_APP_. You can read them from the client code like this: import.meta.env.REACT_APP_SOME_VAR_NAME source (https://wasp-lang.dev/docs/project/env-vars). In production, you should provide client environment variables to the build command, for example: REACT_APP_SOME_VAR_NAME=somevalue npm run build. This is done during the build process, so the value is embedded into the client code source (https://wasp-lang.dev/docs/project/env-vars#defining-env-vars-in-production). If you're deploying your project to Fly.io, you can define server environment variables using the flyctl CLI tool: flyctl secrets set SOME_VAR_NAME=somevalue source (https://wasp-lang.dev/docs/project/env-vars#defining-env-vars-in-production). From the Discord conversation, it seems that you can set client environment variables when using wasp deploy fly deploy by doing REACT_APP_SOME_VAR_NAME=somevalue wasp deploy fly deploy source (https://discord.com/channels/686873244791210014/1220070515276775516). Please ensure that you have correctly set the REACT_APP_STRIPE_CUSTOMER_PORTAL environment variable in your production environment and that you are correctly accessing it in your code. If the problem persists, it might be helpful to check the exact point in your code where the error is thrown to further diagnose the issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Wix, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Wix
Wix2w ago
still not working @kapa.ai i have it set on my fly.io dashboard for the client too
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I'm sorry to hear that you're still experiencing issues. From the information provided, it seems like you've correctly set the REACT_APP_STRIPE_CUSTOMER_PORTAL environment variable in your Fly.io dashboard. However, it's important to note that client-side environment variables need to be embedded into the client code during the build process. This means that setting them in the Fly.io dashboard won't have the desired effect, as the client code can't read any environment variables that weren't embedded during the build time (wasp build) source (https://discord.com/channels/686873244791210014/1220070515276775516). To ensure that the REACT_APP_STRIPE_CUSTOMER_PORTAL environment variable is available to your client code, you should define it when running the build command. For example, you can do this by running REACT_APP_STRIPE_CUSTOMER_PORTAL=yourvalue wasp build in your terminal before deploying your application source (https://discord.com/channels/686873244791210014/1220070515276775516). If you're still encountering issues after trying this, it might be helpful to double-check the part of your code that's throwing the error to ensure that you're correctly accessing the environment variable. If the problem persists, please provide more details about your setup and the exact error message you're seeing so we can better assist you. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Wix, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
martinsos
martinsos2w ago
Any more context you can provide? Some logs before or after that error? Btw I don't think you need REACT_APP_STRIPE_CUSTOMER_PORTAL on the server side
Wix
Wix2w ago
figured it out you need to include it in your deploy
Want results from more Discord servers?
Add your server