wasp deploy

ive deployed my app on fly and im getting a browser error when trying to access some routes:

Failed to load resource: net::ERR_FAILEDUnderstand this error ai-assistant:1 Access to XMLHttpRequest at 'https://petall-server.fly.dev/auth/me' from origin 'https://petall.ke' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.Understand this error petall-server.fly.dev/auth/me:1

Failed to load resource: net::ERR_FAILEDUnderstand this error index-DojbhsmG.js:101 WebSocket connection to 'wss://petall-server.fly.dev/socket.io/?EIO=4&transport=websocket' failed: createSocket @ index-DojbhsmG.js:101Understand this error ai-assistant:1
Failed to load resource: net::ERR_FAILEDUnderstand this error ai-assistant:1 Access to XMLHttpRequest at 'https://petall-server.fly.dev/auth/me' from origin 'https://petall.ke' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.Understand this error index-DojbhsmG.js:78

GET https://petall-server.fly.dev/auth/me net::ERR_FAILED 503 (Service Unavailable) (anonymous) @ index-DojbhsmG.js:78 xhr @ index-DojbhsmG.js:78 H9 @ index-DojbhsmG.js:80 Promise.then _request @ index-DojbhsmG.js:81 request @ index-DojbhsmG.js:80 pd.<computed> @ index-DojbhsmG.js:81 (anonymous) @ index-DojbhsmG.js:76 PO.Zk.queryCacheKey @ index-DojbhsmG.js:81 queryFn @ index-DojbhsmG.js:81 p @ index-DojbhsmG.js:40 A @ index-DojbhsmG.js:40 (anonymous) @ index-DojbhsmG.js:40 Promise.then (anonymous) @ index-DojbhsmG.js:40Understand this error ai-assistant:1 what am i missing?
44 Replies
kapa.ai
kapa.ai4mo ago
Hi @Bruno Njeru. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The CORS error you're seeing (No 'Access-Control-Allow-Origin' header is present on the requested resource) means your backend (https://petall-server.fly.dev) is not allowing requests from your frontend domain (https://petall.ke). This is a common issue when deploying Wasp apps, especially when using custom domains. What you need to do: 1. Set the WASP_WEB_CLIENT_URL environment variable on your server deployment. - This tells your Wasp backend which frontend origin to allow for CORS. - For Fly.io, you should run:
wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://petall.ke>

wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=<https://petall.ke>

- Make sure to replace <https://petall.ke> with your actual frontend domain if it's different. 2. Redeploy your server after setting the environment variable. - This ensures the new CORS configuration is picked up. 3. Double-check your DNS and deployment. - Ensure your frontend is actually being served from <https://petall.ke> and that your backend is reachable at <https://petall-server.fly.dev.> Why this works:
Wasp uses the WASP_WEB_CLIENT_URL environment variable to configure CORS headers on the backend, allowing only requests from your frontend domain. If this is not set correctly, the backend will reject requests from your frontend with a CORS error. This is documented in the Wasp deployment docs for Fly.io and manual deployments see here and here. Extra tip:
If you change your frontend domain or add more domains, you need to update this environment variable accordingly. If you still see issues after this, make sure you have redeployed both the client and server, and that there are no typos in your domain names. Let me know if you need more help! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP4mo ago
i already run this wasp deploy fly cmd --context server secrets set WASP_WEB_CLIENT_URL=https://petall.ke @kapa.ai
Pet All
Pet All
Your apps main description and features.
kapa.ai
kapa.ai4mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- If you've already set WASP_WEB_CLIENT_URL=<https://petall.ke> as a secret for your server on Fly.io, but are still getting CORS errors, here are some things to check based on the official Wasp documentation and community discussions: 1. Redeploy the Server
After setting the secret, you must redeploy your server for the new environment variable to take effect. If you haven't done this, run:
wasp deploy fly deploy

wasp deploy fly deploy

This step is required for the backend to pick up the new CORS configuration see docs. 2. Check for Trailing Slash
There have been issues reported where a trailing slash in the WASP_WEB_CLIENT_URL can cause CORS errors. Make sure your value is exactly <https://petall.ke> (no trailing slash) see discussion. 3. Frontend Domain Must Match Exactly
The value of WASP_WEB_CLIENT_URL must match the origin of your frontend exactly, including protocol (<https://>), and must not include a trailing slash. 4. DNS and Deployment
Ensure that your frontend is actually being served from <https://petall.ke> and that there are no DNS or SSL issues. If your domain is not resolving or is misconfigured, CORS errors can also occur see community troubleshooting. 5. Check for Other CORS-Related Issues
If you have custom HTTP API endpoints, make sure you have set up CORS middleware correctly for those endpoints as well. Wasp requires explicit CORS configuration for custom APIs using middleware, as described in the docs Making Sure CORS Works. 6. WebSocket Issues
The WebSocket error may also be related to CORS or to the server not being up. Make sure your server is running and accessible. Summary:
- Double-check the value of WASP_WEB_CLIENT_URL (no trailing slash, correct protocol). - Redeploy your server after setting the secret. - Ensure your frontend is live at the specified domain. - If using custom APIs, ensure CORS middleware is set up. If you have done all of the above and still see the error, please provide more details about your deployment steps and any custom server configuration you may have. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP4mo ago
still getting cors errors Access to XMLHttpRequest at 'https://petall-server.fly.dev/auth/me' from origin 'https://petall.ke' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. @kapa.ai in the dev environment the server listens on port 3001. what is the equivalent in production? where should the client link with the server?or am I missing something
kapa.ai
kapa.ai4mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- In production, your Wasp server does not listen on port 3001 as it does in development. Instead, it listens on the default HTTP/HTTPS ports (80/443) as managed by your hosting provider (e.g., Fly.io). The server is accessible via the public URL assigned by your provider, such as <https://petall-server.fly.devsee docs. How the client links to the server in production: - In production, your client (frontend) must know the public URL of your server. You set this in the client’s environment variable:
REACT_APP_API_URL=<https://petall-server.fly.dev>

REACT_APP_API_URL=<https://petall-server.fly.dev>

This tells the frontend where to send API requests. Wasp uses this value to configure the client’s API endpoint see docs. - On the server side, you must set the WASP_WEB_CLIENT_URL environment variable to your frontend’s public URL (e.g., <https://petall.ke>). This tells the backend which origin to allow for CORS see docs. Checklist: 1. On your client deployment (e.g., Netlify, Vercel), set:
REACT_APP_API_URL=<https://petall-server.fly.dev>

REACT_APP_API_URL=<https://petall-server.fly.dev>

2. On your server deployment (Fly.io), set:
WASP_WEB_CLIENT_URL=<https://petall.ke>

WASP_WEB_CLIENT_URL=<https://petall.ke>

3. Redeploy both client and server after setting these variables. Summary:
- In production, the server is accessed via its public URL, not localhost:3001. - The client must be configured to use the server’s public URL. - The server must be configured to allow the client’s public URL for CORS. If you have set both environment variables correctly and redeployed, but still get CORS errors, double-check for typos, trailing slashes, or mismatched protocols (http vs https). If the problem persists, there may be a deeper configuration issue, but the above steps are the standard Wasp setup for production see docs. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP4mo ago
so if i set the var on deploy will that automatically set the cors policy? @kapa.ai
toticozeni
toticozeni4mo ago
Hwy @Bruno Njeru , did you follow the the docs when setting up the domain? We have a section for that https://wasp.sh/docs/deployment/deployment-methods/cli#using-a-custom-domain-for-your-app .
Wasp CLI | Wasp
Wasp CLI can deploy your full-stack application with only a single command.
Bruno Njeru
Bruno NjeruOP4mo ago
yes i did @toticozeni
toticozeni
toticozeni4mo ago
@Bruno Njeru Hm, server will setup CORS for WASP_WEB_CLIENT_URL automatically. So if the env vars are set okay (WASP_SERVER_URL on client, and WASP_WEB_CLIENT_URL on server) it shouldn't be a CORS problem. It could be that server is not running, or that you have wrong server url. If you open your server URL it should return 200 OK, as that is the default heath check. I don't seem to be getting that at https://petall-server.fly.dev/. Could you open up the fly dashboard and chec the status and logs of your server?
Bruno Njeru
Bruno NjeruOP3mo ago
where do i set env var for WASP_SERVER_URL @toticozeni @kapa.ai
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- You set the WASP_SERVER_URL environment variable on your server deployment (for example, on Fly.io, Heroku, or Railway). This variable should be set in your server's environment, just like WASP_WEB_CLIENT_URL and JWT_SECRET. For Fly.io, you set it using the Fly CLI:
flyctl secrets set WASP_SERVER_URL=<https://<your-server-domain>>
flyctl secrets set WASP_SERVER_URL=<https://<your-server-domain>>
Replace <your-server-domain> with your actual server URL, such as <https://petall-server.fly.devsee docs. For Heroku, you set it with:
heroku config:set --app <app-name> WASP_SERVER_URL=<url_of_where_server_will_be_deployed>
heroku config:set --app <app-name> WASP_SERVER_URL=<url_of_where_server_will_be_deployed>
see docs For Railway, you add it in the Variables tab in the Railway dashboard for your server service see docs. Summary:
Set WASP_SERVER_URL as an environment variable in your server's deployment environment, using the method appropriate for your hosting provider. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
i have added the wasp_server_url env var but still getting a cors error in the browser Access to XMLHttpRequest at 'https://petall-server.fly.dev/auth/me' from origin 'https://petall.ke' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.Understand this error petall-server.fly.dev/auth/me:1

Failed to load resource: net::ERR_FAILED What am i missing @kapa.ai @toticozeni
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the official Wasp documentation and community discussions, the most common cause of this CORS error in production is an incorrect or missing WASP_WEB_CLIENT_URL environment variable on your server deployment. The WASP_SERVER_URL variable is important for OAuth and redirects, but CORS is controlled by WASP_WEB_CLIENT_URL see docs. Checklist to resolve CORS errors: 1. Set WASP_WEB_CLIENT_URL on your server deployment
This must be set to the exact origin of your frontend, e.g.:
WASP_WEB_CLIENT_URL=<https://petall.ke>

WASP_WEB_CLIENT_URL=<https://petall.ke>

Make sure there is no trailing slash—trailing slashes have been shown to cause CORS errors in Wasp deployments see discussion. 2. Redeploy your server after setting the variable
The new environment variable will only take effect after a redeploy. 3. Double-check your frontend is being served from the exact domain
The value of WASP_WEB_CLIENT_URL must match the frontend’s origin exactly, including protocol (<https://>), and must not include a trailing slash. 4. No need to set WASP_SERVER_URL for CORS
WASP_SERVER_URL is used for OAuth and redirects, not for CORS. The CORS policy is determined solely by WASP_WEB_CLIENT_URL see docs. 5. If using custom HTTP API endpoints
If you have custom APIs, you may need to explicitly enable CORS for those endpoints using middleware as described in the docs see here. Summary:
- Make sure WASP_WEB_CLIENT_URL is set to <https://petall.ke> (no trailing slash) on your server deployment. - Redeploy your server after setting the variable. - Double-check your frontend is served from <https://petall.ke.> If you have done all of the above and are still seeing CORS errors, please provide details about your deployment steps and any custom server configuration, as there may be a deeper configuration issue. The knowledge sources do not mention any other required steps for standard Wasp deployments. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
i have already set wasp_web_client_url and still getting the error @kapa.ai
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- If you have already set the WASP_WEB_CLIENT_URL environment variable on your server deployment (e.g., Fly.io) to <https://petall.ke> (with no trailing slash) and redeployed, but you are still getting CORS errors, here are the next steps and considerations based strictly on the knowledge sources: 1. Check for Trailing Slash and Exact Match
The value of WASP_WEB_CLIENT_URL must match your frontend's origin exactly, including protocol and no trailing slash. Even a small mismatch (like a trailing slash or using http instead of https) will cause CORS to fail see discussion. 2. Redeploy After Setting the Variable
The server must be redeployed after setting or changing the environment variable for the new value to take effect see docs. 3. Custom HTTP API Endpoints
If you are using custom HTTP API endpoints, you may need to explicitly enable CORS for those endpoints using middleware. Wasp does not automatically apply CORS to custom APIs; you must configure it via apiNamespace and middleware as described in the docs see here and GitHub issue. 4. Check for Other Configuration Issues
If you have ejected or customized your server code, or if you are using advanced middleware, ensure that CORS is not being overridden or misconfigured elsewhere see GitHub issue. 5. No Further Steps Documented
The knowledge sources do not provide additional troubleshooting steps beyond the above. If you have verified all of these and the error persists, the sources do not contain enough information to provide a definitive solution. Summary:
- Double-check the exact value of WASP_WEB_CLIENT_URL (no trailing slash, correct protocol, matches frontend origin). - Redeploy your server after setting the variable. - If using custom APIs, ensure CORS middleware is set up for them. - If all of the above are correct and the error persists, the knowledge sources do not contain enough information to resolve your issue further. If you can share more about your custom API setup or middleware configuration, I can help you check those details against the documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
i set it again and this is the fly cli log 🚀 Running server command: flyctl secrets set WASP_WEB_CLIENT_URL=https://petall.ke $ cd /home/bryan/PetTreat/pets/app/.wasp/build $ flyctl secrets set WASP_WEB_CLIENT_URL=https://petall.ke Updating existing machines in 'petall-server' with rolling strategy
[2/2] Updating 3d8d4256ce2008 [app] [2/2] Updating 3d8d4256ce2008 [app] [1/2] Updating 32876295b0e618 [app] [1/2] Updating 32876295b0e618 [app]
✔ [1/2] Machine 32876295b0e618 [app] update succeeded
[2/2] Waiting for 3d8d4256ce2008 [app] to have state: started [2/2] Machine 3d8d4256ce2008 [app] has state: started [2/2] Checking that 3d8d4256ce2008 [app] is up and running
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:1b:2141:a7b:450:5df6:84cf:2]:22 ✔ [2/2] Machine 3d8d4256ce2008 [app] update succeeded Checking DNS configuration for petall-server.fly.dev @kapa.ai
Pet All
Pet All
Your apps main description and features.
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on your Fly.io CLI log, the key issue is in this warning:
**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
This means your server is
not listening on the correct network interface and/or port. As a result, Fly.io cannot route requests to your app, which would explain both the CORS errors and the failed resource loads. What you should do: 1. Ensure your server listens on 0.0.0.0 and the correct port. - By default, Wasp’s production server should listen on port 8080 for Fly.io, as set by the PORT environment variable. - You should set the PORT secret on Fly.io:
flyctl secrets set PORT=8080

flyctl secrets set PORT=8080

- Make sure your server is configured to listen on 0.0.0.0, not just localhost. 2.
Check your deployment steps. - The Wasp Fly.io deployment guide instructs you to set the PORT secret and ensure your app is listening on that port. - If you missed this step, your app will not be reachable, and you will see the warning you posted. 3. Redeploy after setting the correct secrets. - After setting the PORT secret, redeploy your server so it picks up the new configuration. Summary:**
Your app is not reachable because it is not listening on the expected address/port for Fly.io. Set the PORT secret to 8080 and ensure your server listens on 0.0.0.0:8080, then redeploy. This should resolve the connectivity and CORS issues, as the server will then be accessible to Fly.io’s proxy and your frontend see docs. If you continue to have issues after this, please share your server start command or any custom configuration you may have. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
can i run wasp deploy fly cmd --context server secrets set PORT=8080 @kapa.ai or do i have to use the flyctl command
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Yes, you can use the Wasp CLI to set secrets (including PORT) for your Fly.io server deployment. The correct command is:
wasp deploy fly cmd --context server secrets set PORT=8080
wasp deploy fly cmd --context server secrets set PORT=8080
This is documented in the Wasp CLI deployment docs, which show how to run arbitrary Fly commands (like setting secrets) through the Wasp CLI interface see here. So, you do not have to use the flyctl command directly; using the Wasp CLI as shown above is supported and recommended for consistency with your Wasp project. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
still getting the browser cors errors @kapa.ai and when i run wasp deploy i get 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:8080 where should i configure the port to listen at 8080
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To resolve the warning and CORS errors, you need to ensure your Wasp server is listening on the correct port (8080) and on the correct network interface (0.0.0.0) in production on Fly.io. Where to configure the port: - Set the PORT environment variable to 8080 on your Fly.io server deployment.
You can do this using the Wasp CLI:
wasp deploy fly cmd --context server secrets set PORT=8080

wasp deploy fly cmd --context server secrets set PORT=8080

This tells your Wasp server to listen on port 8080, which is what Fly.io expects for routing traffic to your app see docs. - No need to manually change code for the network interface:
Wasp’s production server is designed to listen on 0.0.0.0 by default when deployed, so setting the PORT environment variable is usually sufficient. After setting the secret: - Redeploy your server so the new environment variable takes effect. If you have set PORT=8080 as described and redeployed, but still see the warning, double-check that the secret is set for the correct Fly.io app and context. If the problem persists after these steps, the knowledge sources do not provide further troubleshooting details for this specific issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
port is set to 8080, and internal port for the fly server as well as the reactappurl is set to the fly server url. but still getting this error 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:8080 @kapa.ai what is missing here?
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
port is set to 8080, and internal port for the fly server as well as the reactappurl is set to the fly server url. but still getting this error 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:8080 @kapa.ai what is missing here? is there somewhere else i need to set the port?
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the official Wasp documentation, if you have set the PORT environment variable to 8080 for your Fly.io server deployment (using wasp deploy fly cmd --context server secrets set PORT=8080), and you are still seeing the 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:8080
then, according to the knowledge sources, there is no additional documented place where you need to set the port. Wasp’s production server is expected to listen on the port specified by the PORT environment variable, and Fly.io expects this to be 8080 see docs. The documentation does not mention any need to manually configure the bind address (such as 0.0.0.0) in Wasp’s generated code or any other place to set the port. It is expected to work out of the box when the PORT variable is set and the server is redeployed. If you are still seeing this warning after following the documented steps, the knowledge sources do not provide further troubleshooting steps or mention any additional configuration required. This may indicate an issue outside the scope of the current Wasp documentation, such as a problem with the generated server code or a Fly.io-specific configuration not covered in the docs. Summary:
- Set PORT=8080 as a secret for your Fly.io server deployment. - Redeploy your server. - There is no other documented place to set the port in Wasp. - If the warning persists, the knowledge sources do not contain enough information to resolve this specific issue. For further help, you may need to reach out to the Wasp community or check for updates in the official documentation or Discord support threads, as this scenario is not fully addressed in the current knowledge sources. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
Anyone faced the same issue/knows a way around the cors error/fly error 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:8080 @Wasp Team or should i set the vite config?
MEE6
MEE63mo ago
Wohooo @Bruno Njeru, you just became a Waspeteer level 5!
Bruno Njeru
Bruno NjeruOP3mo ago
Anyone faced the same issue/knows a way around the cors error/fly error 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:8080 @kapa.ai
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the knowledge sources, this issue has come up in the Wasp and Fly.io community before. The CORS error and the Fly.io warning:
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:8080
are typically related to the server not listening on the correct port or network interface as expected by Fly.io. What the Wasp docs and community say: - You must set the PORT environment variable to 8080 for your Fly.io server deployment. This is done with:
wasp deploy fly cmd --context server secrets set PORT=8080

wasp deploy fly cmd --context server secrets set PORT=8080

or
flyctl secrets set PORT=8080

flyctl secrets set PORT=8080

See official docs. - After setting the secret, you must redeploy your server so the new environment variable takes effect. - Wasp’s production server is expected to listen on the port specified by the PORT environment variable, and on 0.0.0.0 (the default for Node.js in production). There is no mention in the knowledge sources of needing to manually change the bind address in the generated code. - If you have set PORT=8080 and redeployed, but still see the warning, the knowledge sources do not provide further troubleshooting steps or mention any additional configuration required. This may indicate an issue outside the scope of the current Wasp documentation or a problem with the generated server code or Fly.io configuration not covered in the docs. Summary:
- Set PORT=8080 as a secret for your Fly.io server deployment. - Redeploy your server. - There is no other documented place to set the port or bind address in Wasp. - If the warning persists, the knowledge sources do not contain enough information to resolve this specific issue. If you continue to experience this problem after following the above steps, you may need to seek help from the Wasp community or Fly.io support, as this scenario is not fully addressed in the current knowledge sources. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
should i set the port in vite config? @kapa.ai
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- You only need to set the port in your Vite config if you want to change the development server port for your client (frontend) when running locally. This is done by adding a port option in your vite.config.js or vite.config.ts file, for example:
// vite.config.js
export default {
server: {
port: 4000,
},
}
// vite.config.js
export default {
server: {
port: 4000,
},
}
However, this does not affect your production server on Fly.io. The production server port is controlled by the PORT environment variable on your server deployment, not by the Vite config. The Vite config is only relevant for local development and the static build process of your client app see docs. So, do not set the production port in your Vite config—set it via the PORT environment variable for your server deployment on Fly.io. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
still getting the cors error in the browser Access to XMLHttpRequest at 'https://petall-server.fly.dev/auth/me' from origin 'https://petall.ke' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. anyone can think of a solution? @kapa.ai @Wasp Team
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- You're still seeing the CORS error:
Access to XMLHttpRequest at 'https://petall-server.fly.dev/auth/me' from origin 'https://petall.ke' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Based on the official Wasp documentation and community discussions, here are the key things to check: 1. WASP_WEB_CLIENT_URL must be set on the server
Make sure the environment variable WASP_WEB_CLIENT_URL is set to <https://petall.ke> (no trailing slash) on your Fly.io server deployment. This is the value Wasp uses to configure CORS and allow requests from your frontend see docs. 2. Redeploy the server after setting the variable
Any change to environment variables requires a redeploy for the new value to take effect. 3. Frontend must be served from the exact domain
The value of WASP_WEB_CLIENT_URL must match the frontend's origin exactly, including protocol and no trailing slash. 4. No need to set CORS in Vite config for production
The Vite config only affects the development server, not the production backend or CORS headers. 5. If using custom HTTP API endpoints
If you have custom APIs, you may need to explicitly enable CORS for those endpoints using middleware as described in the docs see here. 6. Server must be reachable
If your server is not listening on the correct port/interface (should be 0.0.0.0:8080 for Fly.io), Fly.io will not be able to route requests, and you will see both CORS errors and warnings in the Fly logs. Make sure the PORT environment variable is set to 8080 and that you have redeployed after setting it see docs. If you have done all of the above and are still seeing the error, the knowledge sources do not provide further troubleshooting steps for this specific scenario. In that case, it may be helpful to reach out to the Wasp community or check for updates in the official documentation or Discord support threads, as this scenario is not fully addressed in the current knowledge sources. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
Bruno Njeru
Bruno NjeruOP3mo ago
these are the live logs on fly server@0.0.0 validate-env 2025-06-04T23:55:25.820 app[32876295b0e618] lhr [info] > node -r dotenv/config ./scripts/validate-env.mjs 2025-06-04T23:55:26.772 app[32876295b0e618] lhr [info] 🔍 Validating environment variables... 2025-06-04T23:55:32.531 proxy[32876295b0e618] lhr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? 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)
toticozeni
toticozeni3mo ago
Could you do this @Bruno Njeru? You could also access the secrets through the website UI and check if they are correct? We could also check to see if the server url is correct. https://fly.io/dashboard
miho
miho3mo ago
Gist
Multiple domains for CORS - custom global middleware in Wasp 0.12+
Multiple domains for CORS - custom global middleware in Wasp 0.12+ - main.wasp
miho
miho3mo ago
If you are trying to use multiple client domains Otherwise, it should be just the env variables Franjo mentioned
Bruno Njeru
Bruno NjeruOP3mo ago
@toticozeni the main env vars here are WASP_WEB_CLIENT_URL, WASP_SERVER_URL and REACT_APP_API_URL. where should i set the vars, WASP_WEB_CLIENT_URL is set on the server, are the others set on the client?
miho
miho3mo ago
server -> WASP_WEB_CLIENT_URL, WASP_SERVER_URL client -> REACT_APP_API_URL
Bruno Njeru
Bruno NjeruOP3mo ago
this is from the startup log 2025-06-05T13:33:45.417 app[32876295b0e618] lhr [info] > node -r dotenv/config ./scripts/validate-env.mjs 2025-06-05T13:33:45.480 app[32876295b0e618] lhr [info] 🔍 Validating environment variables... 2025-06-05T13:33:46.561 proxy[32876295b0e618] lhr [info] waiting for machine to be reachable on 0.0.0.0:8080 (waited 5.342678656s so far) 2025-06-05T13:33:46.564 proxy[32876295b0e618] lhr [info] waiting for machine to be reachable on 0.0.0.0:8080 (waited 5.345636117s so far) 2025-06-05T13:33:46.663 proxy[32876295b0e618] lhr [info] waiting for machine to be reachable on 0.0.0.0:8080 (waited 5.444851841s so far) 2025-06-05T13:33:46.764 proxy[32876295b0e618] lhr [info] waiting for machine to be reachable on 0.0.0.0:8080 (waited 5.545960941s so far) then later 2025-06-05T13:34:01.116 app[32876295b0e618] lhr [info] INFO [fly api proxy] listening at /.fly/api 2025-06-05T13:34:01.124 runner[32876295b0e618] lhr [info] Machine started in 817ms 2025-06-05T13:34:01.433 runner[3d8d4256ce2008] lhr [info] Machine started in 824ms 2025-06-05T13:34:01.656 app[3d8d4256ce2008] lhr [info] 2025/06/05 13:34:01 INFO SSH listening listen_address=[fdaa:1b:2141:a7b:450:5df6:84cf:2]:22 2025-06-05T13:34:01.702 proxy[3d8d4256ce2008] lhr [error] [PM05] failed to connect to machine: gave up after 15 attempts (in 9.3238799s) 2025-06-05T13:34:01.934 proxy[32876295b0e618] lhr [error] [PC01] instance refused connection. is your app listening on 0.0.0.0:8080? 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) i have set all the variables and PORT=8080 as well. Should i try other ports? maybe they will work? @toticozeni @miho @kapa.ai
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the knowledge sources, you should not try other ports. Fly.io expects your app to listen on port 8080 on the 0.0.0.0 interface, and this is the port documented in the official Wasp deployment instructions for Fly.io (see docs). Setting the PORT environment variable to 8080 is the correct and only documented approach. Your logs indicate that the Fly.io proxy is unable to connect to your app on 0.0.0.0:8080, which means your server process is either not starting, not listening on the correct interface, or exiting before it binds to the port. The knowledge sources do not mention using any other port, nor do they provide steps for changing the bind address in Wasp’s generated code. Key points from the knowledge sources: - Wasp’s production server is expected to listen on the port specified by the PORT environment variable, and on 0.0.0.0 (see docs). - There is no mention of needing to manually change the bind address or port in the generated code. - If you have set PORT=8080 and redeployed, but still see this error, the knowledge sources do not provide further troubleshooting steps or mention any additional configuration required. Summary:
- Do not try other ports; use 8080 as documented. - Ensure PORT=8080 is set as a secret for your Fly.io server deployment. - Redeploy your server after setting the variable. - If the error persists, the knowledge sources do not contain enough information to resolve this specific issue. For further help, you may need to reach out to the Wasp community or Fly.io support, as this scenario is not fully addressed in the current knowledge sources. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Bruno Njeru, 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?
miho
miho3mo ago
This looks to me like your server is not starting (maybe missing some env variable you have locally), you need to restart the server app and see the server logs
Bruno Njeru
Bruno NjeruOP3mo ago
Thanks @miho it was a missing env var.
miho
miho3mo ago
Nice, I'm glad it worked out 🙂

Did you find this page helpful?