Building wasp apps: Easy. Deploying wasp apps: ?!@#$
I've tried deploying the back-end with 1) Docker 2) Node 3) "wasp start" reverse proxied behind Apache
None of those work. All behave the same way. I can access my routes (e.g. /api/test) and wasp provided routes (e.g. /api/auth/me /api/auth/email/signup) are 404.
I've given up on deploying on my server (it's just not possible) and am trying Railway
There is a step which says "Open the Settings and go to the Variables tab: click Variable reference and select DATABASE_URL (it will populate it with the correct value)"
We are setting the DATABASE_URL
This step does not auto-populate as suggested. If we do not populate the field, it remains empty.
If I go, in railway, to the postgres block, I can find a DATABASE_URL to copy, so I populate the server's DATABASE_URL with it.
When my server starts, it crashes, claiming not to have a DATABASE_URL:
------
Error: Prisma schema validation - (get-config wasm)
Error code: P1012
error: Error validating datasource
db
: You must provide a nonempty URL. The environment variable DATABASE_URL
resolved to an empty string.
--> schema.prisma:4
|
3 | provider = "postgresql"
4 | url = env("DATABASE_URL")
------
Looking at the DATABASE_URL, it appears to be populated with the values we copied from the Postgres block in Railway (e.g. postgresql://postgres:[email protected]:5432/railway)
We are following the directions for Railway on https://wasp-lang.dev/docs/advanced/deployment/manually step by step, to the letter (have tried twice).
Please advise, over.20 Replies
Hi @Conspyre. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry to hear that you're having trouble deploying your Wasp app on Railway. Let's try to troubleshoot this issue.
Firstly, it's important to ensure that the
DATABASE_URL
environment variable is correctly set in your Railway project settings. This should be the connection string to your PostgreSQL database. According to the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#4-deploying-the-database), any PostgreSQL database will do, as long as you provide the server with the correct DATABASE_URL
env var and ensure that the database is accessible from the server.
In the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-the-server), it's mentioned that you should go into the Railway dashboard and set up the required env variables. You should click Variable reference and select DATABASE_URL
. It should populate it with the correct value. If it doesn't, you can manually copy the DATABASE_URL
from the Postgres block in Railway, as you've done.
However, it seems like there's an issue with the DATABASE_URL
not being recognized by Prisma. There's a Github issue (https://github.com/wasp-lang/wasp/issues/1321) that mentions a similar error. It's possible that this is a bug in Wasp or Prisma.
Another Github issue (https://github.com/wasp-lang/wasp/issues/940) mentions that the .server.env
gets built as .wasp/out/server/.env
and Prisma explicitly notes support for this. So, it might be worth checking if the DATABASE_URL
is correctly set in this file.
If you're still having trouble, I would recommend reaching out to the Wasp community on their Discord server (https://discord.com/channels/686873244791210014/1204701955679854602) or opening a new issue on their Github page (https://github.com/wasp-lang/wasp/issues). They might be able to provide more specific help.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Conspyre, 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?Solved, I had not included the "https://" at the head of the WASP_WEB_CLIENT_URL and WASP_SERVER_URL. @kapa.ai now there is a CORS issue.
I went to make a change to solve CORS, I added one .js file and a bit in main.wasp and redeployed.
Now the server crashes on deployment. The crash is in generated code. Here is the log:
...
#13 [server-builder 2/11] WORKDIR /app
#14 [server-builder 3/11] COPY src ./src
#15 [server-builder 7/11] COPY sdk .wasp/out/sdk
#16 [server-builder 8/11] RUN npm install && cd .wasp/build/server && npm install
#17 [server-builder 10/11] RUN cd .wasp/build/server && npx prisma generate --schema='../db/schema.prisma'
#18 [server-builder 11/11] RUN cd .wasp/build/server && npm run bundle
#18 0.921 > [email protected] bundle
#18 0.921 > rollup --config --silent
#18 1.146 [!] RollupError: Could not resolve "../../../../src/serverSetup.js" from "src/server.ts"
#18 1.146 src/server.ts
#18 1.146 at getRollupError (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:282:41)
#18 1.146 at Object.error (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:278:42)
#18 1.146 at ModuleLoader.handleInvalidResolvedId (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:20364:36)
#18 1.146 at /app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:20324:26
#18 ERROR: process "/bin/sh -c cd .wasp/build/server && npm run bundle" did not complete successfully: exit code: 1
-----
Suggestions?
Let me check the knowledge base for you. One moment! :books:
----------------------
I'm sorry to hear that you're encountering issues with your deployment. The error message suggests that Rollup, a module bundler, is unable to resolve the path to your
serverSetup.js
file from server.ts
.
Here are a few things you could try:
1. Check the file path: Ensure that the path to serverSetup.js
is correct in your server.ts
file. The error message suggests that Rollup is trying to resolve the path from src/server.ts
, so you might need to adjust the relative path accordingly.
2. Check the file existence: Make sure that the serverSetup.js
file actually exists in the specified location.
3. Rebuild your Wasp project: Run wasp build
again in your project directory before deploying. This command will rebuild your app, which might resolve the issue if it was caused by a temporary glitch or outdated build artifacts.
If you're still encountering issues after trying these steps, I would recommend reaching out to the Wasp community on their Discord server (https://discord.com/channels/686873244791210014/1207206194872057917) for further assistance. They might be able to provide more specific help or insights based on their experience with similar issues.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Conspyre, 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?@kapa.ai I am looking at the generated file .wasp/build/server/src/server.ts and it has a relative path import '../../../../src/serverSetup.js'. I believe this is the bug I have reported where something in the project causes the build to silently "fail" where relative imports no longer work. This bug was marked as closed, I believe erroneously, as it is still affecting my project.
Please see https://github.com/wasp-lang/wasp/issues/2271
Do you have some suggestions on porting a wasp-lang project to Flask? I've spent 4 days on deploying this and it seems not to be possible. 😦
Let me check the knowledge base for you. One moment! :books:
----------------------
I'm sorry to hear about the issues you've been facing with deploying your Wasp project. It seems like you've encountered a bug that's affecting the build process. I recommend keeping the conversation going on the Github issue (https://github.com/wasp-lang/wasp/issues/2271) you've opened, as the Wasp team and community can provide the most accurate help.
As for porting your Wasp project to Flask, it's important to note that Wasp and Flask are quite different. Wasp is a DSL for building full-stack web apps with less boilerplate, while Flask is a micro web framework for Python. Here are some general steps you might consider:
1. Backend: Recreate your server-side logic in Flask. This would involve setting up your routes and handlers in Flask to mirror what you have in your Wasp project.
2. Frontend: Wasp uses React for the frontend. You could keep your frontend in React and serve it as static files in Flask.
3. Database: Wasp uses Prisma as an ORM for the database. You would need to replace this with a Python ORM, such as SQLAlchemy, for use with Flask.
4. Deployment: Flask apps can be deployed in numerous ways, including on platforms like Heroku, or using Docker.
Please note that this process could involve a significant amount of work, depending on the complexity of your Wasp project. If you're not familiar with Flask, you might need to spend some time learning about it before you can effectively port your project.
If you're still interested in using Wasp, I would recommend reaching out to the Wasp community on their Discord server (https://discord.com/channels/686873244791210014/1207206194872057917) for further assistance. They might be able to provide more specific help or insights based on their experience with similar issues.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Conspyre, 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?
I can deploy Flask apps in my sleep @kapa.ai but I've probed the depths of your knowledge, what's in the wasp docs, and what other LLMs know. Do you have any suggestions on how to reliably deploy a Wasp app before I put this project to rest?
Let me check the knowledge base for you. One moment! :books:
----------------------
I understand your frustration and I'm sorry to hear about the difficulties you've been facing with deploying your Wasp app. Here are some general steps to deploy a Wasp app based on the information from the Wasp documentation and Github issues:
1. Generate Deployable Code: Run
wasp build
to generate deployable code for your entire app in the .wasp/build/
directory. Note that you need to switch to PostgreSQL before deploying to production if you're using SQLite as a database (source (https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-a-wasp-app)).
2. Deploy the API Server (Backend): Deploy the Docker image defined in the .wasp/build
directory to a hosting provider and ensure the required environment variables are correctly set up. The necessary environment variables include DATABASE_URL
, WASP_WEB_CLIENT_URL
, WASP_SERVER_URL
, and JWT_SECRET
if you're using Wasp's auth
features (source (https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-the-api-server-backend)).
3. Deploy the Web Client (Frontend): Build the web client by running npm install && REACT_APP_API_URL=<url_to_wasp_backend> npm run build
in the .wasp/build/web-app
directory. The built web client can be deployed to any static hosting provider (source (https://wasp-lang.dev/docs/advanced/deployment/manually#3-deploying-the-web-client-frontend)).
4. Deploy a PostgreSQL Database: Deploy a PostgreSQL database and ensure it's running. The DATABASE_URL
environment variable should be set to the URL of this database.
5. Update & Redeploy: If you make updates and need to redeploy, run wasp build
to rebuild your app and then repeat the deployment steps (source (https://wasp-lang.dev/docs/advanced/deployment/manually#updates--redeploying)).
If you're still encountering issues, you might want to consider using the Wasp CLI for deployment. The wasp deploy
command can deploy your full-stack application with only a single command, automating the manual deployment process (source (https://wasp-lang.dev/docs/advanced/deployment/cli)).
Lastly, if you're encountering specific issues or bugs, I recommend reaching out to the Wasp community on their Discord server (https://discord.com/channels/686873244791210014/1207206194872057917) or opening a new issue on their Github page (https://github.com/wasp-lang/wasp/issues). They might be able to provide more specific help or insights based on their experience with similar issues.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Conspyre, 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?@kapa.ai update for future travelers, this turned out to be an actual typo in a server filename, so, the import issue I mentioned was not at play & we're at least able to sort of deploy on Railway. 🥳
Let me check the knowledge base for you. One moment! :books:
----------------------
That's great to hear! I'm glad you were able to resolve the issue and successfully deploy your Wasp app on Railway. It's a good reminder of how sometimes, even a small typo can lead to significant issues in software development.
For future reference or for anyone else encountering similar issues, it's always a good idea to double-check your file names and import paths.
If you encounter any more issues or have further questions about Wasp, don't hesitate to ask. Happy coding! 🎉
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Conspyre, 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?
I'd advise against taking Kapa too seriously because it can take you down various weird rabbit holes that are not compatible with Wasp.
I'm sorry you had a hard time deploying Wasp to Ubuntu, but as I said earlier, it's just a React + Node.js + Postgres app. Wasp is as hard to deploy as deploying React + Node.js apps to Ubuntu.
I haven't deployed to a VPS directly but I have used Caprover to make things easier for myself. If you want I can try to deploy and give you a list of steps?
@miho I've spent about a week on deployment. I can "deploy" it with Docker, with Node, and with "wasp start" all reverse proxied through Apache. None of them work, and they all fail the same way. My routes are there. The wasp /api/auth routes are not. They are 404 when the back end is running, and they are 503 when it is not.
Can you spot anything with this apache config? Its the common denominator between all of the broken wasp builds (which always "just works" in dev, none of the problems with prod are seen in dev...) - you're definitely right about @kapa.ai that bot doesn't understand deployment issues.
Let me check the knowledge base for you. One moment! :books:
----------------------
Your Apache configuration seems to be correctly set up for serving static files and proxying API requests to the backend. However, there are a few things you might want to check:
1. Backend Server: Ensure that your backend server is running and listening on
<http://localhost:3001/
.> You can check this by directly accessing the backend server's routes without going through the Apache proxy.
2. API Routes: Make sure that the routes under /api/
are correctly defined in your Wasp project. If they're not, they would return a 404 error.
3. Apache Logs: Check the Apache error and access logs for any clues. The error log might contain useful information about why the requests are failing.
4. Apache and Wasp Interaction: There might be some specific interaction between Apache and Wasp that's causing the issue. You could try deploying your Wasp app without Apache to see if the issue persists.
If you're still encountering issues, I recommend reaching out to the Wasp community on their Discord server (https://discord.com/channels/686873244791210014/1207206194872057917) or opening a new issue on their Github page (https://github.com/wasp-lang/wasp/issues). They might be able to provide more specific help or insights based on their experience with similar issues.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Conspyre, 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 @miho I can't use caprover on this system, it's got another application deployed via Apache. Is it possible to deploy React/Node via Apache?
I've been struggling to route the /auth routes over https. I can run the server all day and it responds over localhost just fine, I've gotten it to respond to the auth routes over http, but over https not so much.
I can make /api routes in my application code work over https, so it's something peculiar to the /auth routes in Wasp, that's all I know. @kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
Yes, it is possible to deploy a React/Node.js application via Apache, but it involves serving the static files generated by React and setting up a reverse proxy for the Node.js server.
However, the issue you're facing seems to be related to routing the
/auth
routes over HTTPS. Here are a few things you might want to check:
1. HTTPS Configuration: Ensure that your Apache server is correctly configured to handle HTTPS requests. This typically involves enabling the mod_ssl
module, creating a virtual host for HTTPS, and specifying the SSL certificate and key files.
2. ProxyPass Directive: In your Apache configuration, you're using the ProxyPass
directive to route /api/
requests to <http://localhost:3001/
.> If your backend server is using HTTPS, you should update this to <https://localhost:3001/
.>
3. Wasp Auth Routes: The /auth
routes are provided by Wasp's built-in authentication feature. If only these routes are having issues, it might be related to how Wasp handles authentication. You might want to check the Wasp authentication documentation (https://wasp-lang.dev/docs/tutorials/todo-app#auth-required) for any potential issues.
If you're still encountering issues, I recommend reaching out to the Wasp community on their Discord server (https://discord.com/channels/686873244791210014/1207206194872057917) or opening a new issue on their Github page (https://github.com/wasp-lang/wasp/issues). They might be able to provide more specific help or insights based on their experience with similar issues.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Conspyre, 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?@kapa.ai Can you show an example apache.conf file that correctly routes /auth routes and /api routes to a wasp server running on localhost:3001?
Let me check the knowledge base for you. One moment! :books:
----------------------
Based on the information provided in the knowledge sources, I don't have a specific example of an Apache configuration file that routes
/auth
and /api
routes to a Wasp server running on localhost:3001
. However, I can provide a general idea of how it might look based on standard Apache configuration practices:
This configuration sets up a reverse proxy that forwards /auth/
and /api/
requests to a Wasp server running on localhost:3001
. Please replace yourdomain.com
with your actual domain.
Please note that this is a simplified example and your actual configuration might need additional settings, especially if you're using HTTPS or have other specific requirements.
For more detailed information on Apache configuration, you might want to refer to the Apache documentation (https://httpd.apache.org/docs/2.4/). If you're still encountering issues, I recommend reaching out to the Wasp community on their Discord server (https://discord.com/channels/686873244791210014/1207206194872057917) or opening a new issue on their Github page (https://github.com/wasp-lang/wasp/issues). They might be able to provide more specific help or insights based on their experience with similar issues.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Conspyre, 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?@kapa.ai @miho can confirm. LLMs do not know how to deploy wasp behind apache. The provided instructions do work for any user provided code in /api routes. They do not route /auth methods private to wasp. LLMs spin on apache confgs for days and seemingly can not converge on a solution.
Let me check the knowledge base for you. One moment! :books:
----------------------
I'm sorry to hear about the difficulties you're experiencing with deploying Wasp behind Apache. Based on the information provided, it seems like there might be a specific issue with how Wasp's
/auth
routes interact with Apache.
Unfortunately, without more specific information about your setup and the issues you're encountering, it's difficult to provide a definitive solution. Here are a few general suggestions:
1. Check Wasp's Auth Routes: Ensure that the /auth
routes are correctly set up in your Wasp project. If they're not, they would return a 404 error.
2. Check Apache's ProxyPass Directives: In your Apache configuration, you should have ProxyPass
directives that route /auth/
requests to your Wasp server. If these directives are not correctly set up, the /auth
routes might not work.
3. Check for HTTPS Issues: If your Wasp server is using HTTPS, you might need to adjust your Apache configuration to handle HTTPS requests correctly. This could involve enabling the mod_ssl
module, creating a virtual host for HTTPS, and specifying the SSL certificate and key files.
4. Check the Apache Logs: The Apache error and access logs might contain useful information about why the /auth
routes are not working. If there are any error messages related to the /auth
routes, they could provide clues about what's going wrong.
If you're still encountering issues, I recommend reaching out to the Wasp community on their Discord server (https://discord.com/channels/686873244791210014/1207206194872057917) or opening a new issue on their Github page (https://github.com/wasp-lang/wasp/issues). They might be able to provide more specific help or insights based on their experience with similar issues.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Conspyre, 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 I seem to have this working by doing a ProxyPass/ProxyPassReverse for /auth, /api and /operations in my apache config, like so:
Force proxy for /auth and /api
ProxyPass /auth http://localhost:3001/auth
ProxyPassReverse /auth http://localhost:3001/auth
ProxyPass /api http://localhost:3001/api
ProxyPassReverse /api http://localhost:3001/api
ProxyPass /operations http://localhost:3001/operations
ProxyPassReverse /operations http://localhost:3001/operations
I have to do more testing & there are a couple of broken pages I haven't found root cause yet, maybe there are more routes to proxy.
I'll play around with it and let you know what I find 🙂