W
Waspβ€’2mo ago
Dom

Signup/Login missing in deployed Wasp app

I'm using the OpenSaaS template to translate my research Python scripts into a SaaS webapp. I am using Wasp v0.15.0 and am developing on macOS with Apple Silicon. Everything works locally, including email signup, login/logout and access control to certain areas of the webapp based on subscriptions status or plan. However, when I deploy to fly.io following the Wasp Deployment guide, one part of the webapp does not work: in my local version, there is a login button in the top right corner of my landing page that, once logged in, turns into a dropdown menu that displays the user email address as seen in the first picture. This part is completely missing in my deployed app as seen in the second picture. During deployment, the terminal output did not hint at any big issues except for this (for the server application), even though I do not think that this causes the described behavior:
(mysaas-server.fly.dev)
WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
- 0.0.0.0:3000
Found these processes inside the machine with open listening sockets:
PROCESS | ADDRESSES
-----------------*-------------------------------------
/.fly/hallpass | [fdaa:b:9982:a7b:5e:593:ded3:5k:21
(mysaas-server.fly.dev)
WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
- 0.0.0.0:3000
Found these processes inside the machine with open listening sockets:
PROCESS | ADDRESSES
-----------------*-------------------------------------
/.fly/hallpass | [fdaa:b:9982:a7b:5e:593:ded3:5k:21
I checked the browser console after cold-starting the client webapp and it said that it failed to load the auth part with error 502. However, when I reloaded the client webapp, this error went away. I figure that this only happened since the server side of my webapp was probably cold-started the first time it failed to load the auth component, and when I reloaded the client webapp, the auth part could actually be fetched (the errors went away) but the actual auth logic and the dropdown menu is still missing. Do you have any idea why this whole part of the webapp is missing on fly.io? Thanks in advance! 🀝🏻
No description
No description
28 Replies
kapa.ai
kapa.aiβ€’2mo ago
Hi @Dom. 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 in the knowledge sources, I can offer some insights and potential solutions to your issue with the missing signup/login functionality in your deployed Wasp app on fly.io. This problem seems similar to issues other users have encountered. 1. Check server logs and network requests: First, it's important to investigate what's happening on the server side. As suggested by Community Member 2 in a similar case, you should check the server logs on Fly.io (https://discord.com/channels/686873244791210014/1217941277979574315) and examine the network requests in your browser's developer tools. This can help identify if the server is receiving requests from the client and if there are any errors being reported. 2. Environment variables: Make sure you've set up all the necessary environment variables for your deployed app. As Community Member 1 mentioned in a support thread (https://discord.com/channels/686873244791210014/1217758453326680095), you might need to set the REACT_APP_API_URL to your server URL. Double-check that all required environment variables are correctly set for your production environment. 3. CORS issues: The problem could be related to CORS (Cross-Origin Resource Sharing) settings. In a similar case (https://discord.com/channels/686873244791210014/1217941277979574315), Community Member 2 suggested that the server might be rejecting requests due to CORS errors. Ensure that your server is configured to accept requests from the correct client URL. 4. Database migrations: If you've made any changes to your database schema, make sure you've run the necessary migrations on your production database. As Community Member 152 reported (https://discord.com/channels/686873244791210014/1217295340785635418), running a database migration and redeploying solved their login/signup issues. 5. Wasp version: Although you're using a newer version (0.15.0), it's worth noting that some users have resolved similar issues by updating to the latest Wasp version. Community Member 8 suggested (https://discord.com/channels/686873244791210014/1201898985300971540) updating Wasp as a potential solution in a similar case. 6. Cold start issues: The 502 error you're seeing on the initial load could indeed be related to a cold start of your server. This is a common issue with serverless deployments. You might want to consider implementing a warm-up strategy or using a paid plan on Fly.io that keeps your instances warm. 7. Custom domain setup: If you're using a custom domain, ensure it's properly set up. Community Member 1 pointed out (https://discord.com/channels/686873244791210014/1201898985300971540) the importance of setting up CNAME records correctly for custom domains on Fly.io. To further debug this issue: 1. Double-check all your environment variables and CORS settings. 2. Examine the server logs on Fly.io for any errors related to authentication or API requests. 3. Use the browser's developer tools to check for any failed network requests or JavaScript errors. 4. Try redeploying your app after ensuring all configurations are correct. If the problem persists after trying these steps, you might want to share more detailed logs or error messages from both the client and server side to get more specific help from the Wasp community. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Dom, 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?
Dom
DomOPβ€’2mo ago
Thank you @kapa.ai , I checked the forum posts you mentioned but didn't find an answer. I did check the fly.io logs for my client and server app and found that I keep getting a recurring error about the STRIPE_API_KEY being undefined. This error happens every time the server app is started, so I figure this causes this issue. I do have a Stripe API key in my .env.server file, and locally the Stripe checkout also works already. Do I have to specifically indicate the Stripe API environment variable when deploying? I understood that Wasp takes care of that for me
Killshot
Killshotβ€’2mo ago
To me this doesn't seem like a Stripe issue, is your web client url and server url including envs properly configured and given to fly CLI?
Filip
Filipβ€’2mo ago
This looks like an app-level error. @Dom Thanks for the great explanation of the error. I assume you are using OpenSaas. @Vinny (@Wasp) Please see if this issue looks familiar to you (check the screenshots).
Vinny (@Wasp)
Vinny (@Wasp)β€’2mo ago
Yes you need to add the env variables to your deployed app. Make sure you follow the instructions here carefully, including going to the Wasp Deployment docs to see how to set your env variables https://docs.opensaas.sh/guides/deploying/
OpenSaaS.sh
Deploying
Open SaaS is a free, open-source, full-stack SaaS starter kit for React + NodeJS.
Vinny (@Wasp)
Vinny (@Wasp)β€’2mo ago
Deploying with the Wasp CLI | Wasp
Wasp CLI can deploy your full-stack application with only a single command.
Dom
DomOPβ€’2mo ago
@Killshot @Filip @Vinny (@Wasp) thanks to all of you for pitching in. After correctly configuring my environment variables the error regarding the Stripe API key went away. I have checked the logs on fly.io and can narrow it down to a communication error between the server and client app. While the myapp-client logs look good...
2024-12-03 20:55:51.531
2024/12/03 19:55:51 INFO SSH listening listen_address=[fdaa:b:9972:a7b:4e:19e4:eb35:2]:22 dns_server=[fdaa::3]:53
2024-12-03 20:55:51.443
machine became reachable in 89.159236ms
2024-12-03 20:55:51.411
7:55PM INF Listening at http://0.0.0.0:8043 /...
2024-12-03 20:55:51.354
machine started in 966.844024ms
2024-12-03 20:55:51.353
Machine started in 962ms
2024-12-03 20:55:51.335
INFO [fly api proxy] listening at /.fly/api
2024-12-03 20:55:51.333
INFO Preparing to run: `/goStatic -fallback index.html` as appuser
2024-12-03 20:55:51.261
INFO Starting init (commit: 5a7554a5a)...
2024-12-03 20:55:50.485
2024-12-03T19:55:50.485463439 [01JE4N77228VFPNRCDP0HX0HBB:main] Running Firecracker v1.7.0
2024-12-03 20:55:50.388
Starting machine
2024-12-03 20:55:51.531
2024/12/03 19:55:51 INFO SSH listening listen_address=[fdaa:b:9972:a7b:4e:19e4:eb35:2]:22 dns_server=[fdaa::3]:53
2024-12-03 20:55:51.443
machine became reachable in 89.159236ms
2024-12-03 20:55:51.411
7:55PM INF Listening at http://0.0.0.0:8043 /...
2024-12-03 20:55:51.354
machine started in 966.844024ms
2024-12-03 20:55:51.353
Machine started in 962ms
2024-12-03 20:55:51.335
INFO [fly api proxy] listening at /.fly/api
2024-12-03 20:55:51.333
INFO Preparing to run: `/goStatic -fallback index.html` as appuser
2024-12-03 20:55:51.261
INFO Starting init (commit: 5a7554a5a)...
2024-12-03 20:55:50.485
2024-12-03T19:55:50.485463439 [01JE4N77228VFPNRCDP0HX0HBB:main] Running Firecracker v1.7.0
2024-12-03 20:55:50.388
Starting machine
... the myapp-server logs are littered with
instance refused connection
instance refused connection
messages:
2024-12-03 20:56:07.399
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-12-03 20:56:01.448
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-12-03 20:55:58.110
Server listening on port 8080
2024-12-03 20:55:58.063
pg-boss started!
2024-12-03 20:55:57.904
Starting pg-boss...
[...]
2024-12-03 20:55:54.423
Prisma schema loaded from ../db/schema.prisma
2024-12-03 20:55:54.281
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-12-03 20:55:53.433
> prisma migrate deploy --schema=../db/schema.prisma
2024-12-03 20:55:53.433
> [email protected] db-migrate-prod
2024-12-03 20:55:52.636
> npm run db-migrate-prod && NODE_ENV=production npm run start
2024-12-03 20:55:52.636
> [email protected] start-production
2024-12-03 20:55:51.738
2024/12/03 19:55:51 INFO SSH listening listen_address=[fdaa:b:9972:a7b:4e:583:ddd3:2]:22 dns_server=[fdaa::3]:53
2024-12-03 20:55:51.493
machine started in 984.97769ms
[...]
INFO Starting init (commit: 5a7554a5a)...
2024-12-03 20:55:50.609
2024-12-03T19:55:50.609528703 [01JE4R274PZFZQEBXBP920BAC2:main] Running Firecracker v1.7.0
2024-12-03 20:55:50.509
Starting machine
2024-12-03 20:56:07.399
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-12-03 20:56:01.448
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-12-03 20:55:58.110
Server listening on port 8080
2024-12-03 20:55:58.063
pg-boss started!
2024-12-03 20:55:57.904
Starting pg-boss...
[...]
2024-12-03 20:55:54.423
Prisma schema loaded from ../db/schema.prisma
2024-12-03 20:55:54.281
[PC01] instance refused connection. is your app listening on 0.0.0.0:3000? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
2024-12-03 20:55:53.433
> prisma migrate deploy --schema=../db/schema.prisma
2024-12-03 20:55:53.433
> [email protected] db-migrate-prod
2024-12-03 20:55:52.636
> npm run db-migrate-prod && NODE_ENV=production npm run start
2024-12-03 20:55:52.636
> [email protected] start-production
2024-12-03 20:55:51.738
2024/12/03 19:55:51 INFO SSH listening listen_address=[fdaa:b:9972:a7b:4e:583:ddd3:2]:22 dns_server=[fdaa::3]:53
2024-12-03 20:55:51.493
machine started in 984.97769ms
[...]
INFO Starting init (commit: 5a7554a5a)...
2024-12-03 20:55:50.609
2024-12-03T19:55:50.609528703 [01JE4R274PZFZQEBXBP920BAC2:main] Running Firecracker v1.7.0
2024-12-03 20:55:50.509
Starting machine
MEE6
MEE6β€’2mo ago
Wohooo @Dom, you just became a Waspeteer level 1!
Dom
DomOPβ€’2mo ago
What stands out to me is that the myapp-server log has a line stating
Server listening on port 8080
Server listening on port 8080
This would obviously explain why the instance refused connection since it needs my app to listen to
0.0.0.0.3000
0.0.0.0.3000
However, my fly-server.toml file (created during first deployment, I did not make any changes to it since) specifies the internal port to 3000:
app = 'myapp-server'
primary_region = 'fra'

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 1
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
app = 'myapp-server'
primary_region = 'fra'

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = 'stop'
auto_start_machines = true
min_machines_running = 1
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
I searched my whole project for any code that specifies this port 8080 but did not find anything. Do you have an idea why myapp-server is listening to the wrong port even though it is specified in the fly-server.toml file? I've also browsed the fly.io forum and found one post talking about the
auto_stop_machines
auto_stop_machines
and
auto_start_machines
auto_start_machines
potentially causing this. While I have not changed my fly-server.toml file to configure the myapp-server app to never shut down, I once manually forced the myapp-server app to start before navigating to the URL of myapp-client, but to no avail. This caused the same instance refused connection message in the logs. https://discord.com/channels/686873244791210014/1308740789316354108/1309439561297821786
Dom
DomOPβ€’2mo ago
Did some more digging and found the solution: the environment variable for PORT was incorrectly set to 8080, so I manually changed it on fly.io under Secrets > PORT to 3000 and re-deployed with my client environment variables and now everything works as intended! πŸš€ Just one final question before I mark this question as solved: when is the PORT variable set to 8080 and why?
Killshot
Killshotβ€’2mo ago
yes i was just gonna say this.... PORT has to be defined as well to 3000
Vinny (@Wasp)
Vinny (@Wasp)β€’2mo ago
oh weird. I can't answer this for you... maybe someone else can. But I'm glad you found the solution. Nice detective work you did there πŸ™‚
NEROX
NEROXβ€’2mo ago
Me :D #Prisma Studio Deployed App (Fly) Check latest message with the solution
Dom
DomOPβ€’2mo ago
Yes, it sounds like you had the same problem @NEROX . Did you ever figure out why your PORT was set to 8080 before manually changing it?
MEE6
MEE6β€’2mo ago
Wohooo @Dom, you just became a Waspeteer level 2!
martinsos
martinsosβ€’2mo ago
Hm yeah, if we had multiple peple with PORT set to 8080, we should look into it for sure. So that port should be set by wasp deploy fly deploy, to 3000, if I am correct. Is it possible that is not happening?
Dom
DomOPβ€’2mo ago
I initially deployed my app without specifying any environment variables, and the PORT environment variable was still defined under Secrets on fly.io. Since you @NEROX also deployed without any environment variables first, I figure that this is some kind of default value that is set if not specified otherwise.
martinsos
martinsosβ€’2mo ago
@Dom but did you deploy with wasp deploy fly deploy? if so, PORT was supposed to be set up for you.
Dom
DomOPβ€’2mo ago
Yes, I did exactly that, including my client environment variables Just forgot to also specify my server enironment variables when I ran this for the first time and added them later when I re-deployed two, three times in the hopes of fixing the port issue
martinsos
martinsosβ€’2mo ago
Ok got it @Dom . That hsouldn't have caused issues though, but I do wonder if those redeployes somehow messed up the PORT variable. Hm weird. I will open an issue for this for us to investigate, thanks for the details.
martinsos
martinsosβ€’2mo ago
GitHub
When deploying on fly, server PORT is set to 8080 instead of 3000? ...
We had two users encounter this situation. It is not clear how that happened -> they used wasp deploy fly deploy and that should have set PORT to 3000, not 8080. We should investigate to figure ...
NEROX
NEROXβ€’2mo ago
From my point of view what makes the port change is that the server explodes more than 10 or 20 times, restarts and then changes the default port.
Vinny (@Wasp)
Vinny (@Wasp)β€’2mo ago
Wait. in our Wasp manual deployment guides it says this regarding the env vars:
The server's HTTP port number. This is where the server listens for requests (default: 3001).
The server's HTTP port number. This is where the server listens for requests (default: 3001).
Ok I just encountered the same issue and I think its becasue the DB failed to launch when running the first deploy command so I had to create a db and set the port to 3000 manually weird I left a comment on the issue above!
martinsos
martinsosβ€’2mo ago
wow 10 or 20 times how does that happen?'
NEROX
NEROXβ€’2mo ago
in my case deploy an app without required vars, I go to make a coffee and then when I enter the server logs I see that it has β€œtried” to restart and compile all those times but as always it is missing some Var. I could recreate the situation by incompletely deploying an app.
martinsos
martinsosβ€’2mo ago
Ok I got it, so missing env vars @miho is currently working on a nice solution for that btw, so soon Waps might be much more helpful about that
miho
mihoβ€’2mo ago
Yeah, that's something we want to avoid! Ideally, the server would tell you "Hey, these 3 env vars are missing, go add them" and die πŸ˜„

Did you find this page helpful?