W
Wasp-langβ€’4mo ago
7Nic

Network error on Sign up after deploy on Fly.io

I have deployed to fly.io and it was working, it's deployed with a specific domain and the certificates are configured. Now a Network Error is ocurring. The browser says it CORS policy error (although I read in other posts here it could be for another reason). There is no error on server logs. I'd rather understand the issue instead of just redeploying. My wasp version is 0.13
No description
No description
16 Replies
kapa.ai
kapa.aiβ€’4mo ago
Hi @7Nic. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided, there could be a few reasons why you're experiencing a network error on sign up after deploying on Fly.io. Here are some steps you can take to troubleshoot the issue: 1. Check your environment variables: Make sure that you have set up your environment variables correctly. In particular, ensure that the WASP_WEB_CLIENT_URL environment variable for your server app is set to your domain. You can set this variable by running the following command:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://yourdomain.com>
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://yourdomain.com>
Replace yourdomain.com with your actual domain. This step is crucial for keeping your CORS configuration up to date (source (https://wasp-lang.dev/docs/advanced/deployment/cli#using-a-custom-domain-for-your-app)). 2. Inspect network activity: Open the developer tools in your browser and check the "Network" tab. Look for any requests that are taking a long time or failing. This could give you a clue as to what's causing the network error. 3. Check your server logs: Even though you mentioned there are no errors in your server logs, it's worth double-checking. Look for any unusual activity or error messages. 4. Redeploy your app: Sometimes, redeploying your app can resolve the issue. You can do this by running wasp deploy fly deploy. If none of these steps resolve the issue, it might be helpful to share more details about the exact error message you're seeing, as well as any relevant code or configuration settings. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @7Nic, 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?
Filip
Filipβ€’4mo ago
Hey @7Nic! The bot's answer is correct, but since you want to understand the details, I'll dig into it. In your case, the issue is indeed a misconfigured CORS policy (official name: same origin policy). In short, this is a browser mechanism that prevents websites from reading the data from other site's servers. The logic is "you wouldn't want someone's blog to read the data from your email that you're signed into in a different tab" The browser enforces this when the origin of the site (voxgen.net) is different than the origin of the server (voxgen-server.fly.dev). Origin is just a fancy name for domain + port + protocol. The browser by default assumes that those domains have nothing to with each other and that voxgen.net has no business reading the data from voxgen-server.fly.dev. To prevent the error, voxgen-server.fly.dev must somehow tell the browser "Hey, it's cool, voxgen.net can read my data" and it does this by attaching an Access-Control-Allow-Origin: voxgen.net header to its responses. Normally, you'd have to configure this header yourself using some kind of middleware, but with Wasp, the framework does it for you. All you need to do is define the WASP_WEB_CLIENT_URL=https://voxgen.net environment variable, and Wasp takes care of setting the header. Hope that clears it up! For more, read: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
IamIconLiving
IamIconLivingβ€’4mo ago
You should be teaching Very nice explanation
7Nic
7NicOPβ€’4mo ago
Thanks! It was that I probably didn't update the domain on redeploys. And indeed you should be teaching πŸ˜†
MEE6
MEE6β€’4mo ago
Wohooo @7Nic, you just became a Waspeteer level 3!
Filip
Filipβ€’4mo ago
Haha, thanks for the praise guys! Glad you got it sorted out @7Nic Anything else I can help you with?
Janus
Janusβ€’4mo ago
Thanks, @sodic for the clear explanation! I have a follow-up question: how can I apply this to a subdomain, such as https://www.voxgen.net ? Is it possible to add an additional WASP_WEB_CLIENT_URL environment variable for this purpose?
MEE6
MEE6β€’4mo ago
Wohooo @Janus, you just became a Waspeteer level 1!
Filip
Filipβ€’4mo ago
You can't do that, but you can do something else that achieves the same thing
Filip
Filipβ€’4mo ago
Stack Overflow
Access-Control-Allow-Origin Multiple Origin Domains?
Is there a way to allow multiple cross-domains using the Access-Control-Allow-Origin header? I'm aware of the *, but it is too open. I really want to allow just a couple domains. As an example,
Filip
Filipβ€’4mo ago
Configuring Middleware | Wasp
Wasp comes with a minimal set of useful Express middleware in every application. While this is good for most users, we realize some may wish to add, modify, or remove some of these choices both globally, or on a per-api/path basis.
Janus
Janusβ€’4mo ago
Thanks @sodic! It worked for me πŸ˜‰
Filip
Filipβ€’4mo ago
Very happy to hear it! How did you find the process? Cumbersome or easy enough?
Janus
Janusβ€’4mo ago
Quite easy! The links you shared were really helpful πŸ‘ Thanks again!
tonykay4307
tonykay4307β€’2mo ago
I deployed to Fly.io and I am getting "network error." After many hours, I still cannot get it to work on Fly.io
Filip
Filipβ€’2mo ago
Hey @tonykay4307, please open a new thread and share the details. Tell us what you tried, what the error is, etc...
Want results from more Discord servers?
Add your server