[CAL-3737] Railway deployment does not work
dipyamanroy opened this issue · comments
Issue Summary
Deployment using Railway shows up as active, however the URL which points to Cal does not load, or loads briefly with error 500.
Steps to Reproduce
- Use the one-click deploy with Railway.
- Add your Google API key, and proceed to deploy both Cal and Postgres.
- Click on URL generated by Railway.
Expected result is a deployment of Cal with a login page.
Actual Results
- Blank page or brief displays of Error 500.
Expected Results
- Login page from Cal
Technical details
Logs from Railway:
@calcom/web:start: SyntaxError: Unexpected token A in JSON at position 0
@calcom/web:start: at JSON.parse (<anonymous>)
@calcom/web:start: at 761191 (/calcom/apps/web/.next/server/pages/auth/login.js:1:12370)
@calcom/web:start: at __webpack_require__ (/calcom/apps/web/.next/server/webpack-runtime.js:1:161)
@calcom/web:start: at /calcom/apps/web/.next/server/pages/auth/login.js:1:11124
@calcom/web:start: at __webpack_require__.a (/calcom/apps/web/.next/server/webpack-runtime.js:1:1070)
@calcom/web:start: at 222186 (/calcom/apps/web/.next/server/pages/auth/login.js:1:10981)
@calcom/web:start: at __webpack_require__ (/calcom/apps/web/.next/server/webpack-runtime.js:1:161)
@calcom/web:start: at /calcom/apps/web/.next/server/pages/auth/login.js:1:6541
@calcom/web:start: at __webpack_require__.a (/calcom/apps/web/.next/server/webpack-runtime.js:1:1070)
@calcom/web:start: at 130133 (/calcom/apps/web/.next/server/pages/auth/login.js:1:6135)
@calcom/web:start: 16:07:46:497 WARNorgDomains.ts Match of WEBAPP_URL with ALLOWED_HOSTNAME failed {
@calcom/web:start: WEBAPP_URL: 'https://cal-production-a4cb.up.railway.app'/;,
@calcom/web:start: ALLOWED_HOSTNAMES: []
@calcom/web:start: }
Evidence
The error logs indicate two primary issues with your Railway deployment of Cal: a JSON syntax error and a domain matching warning. Here's how to address them:
-
JSON Syntax Error: This likely stems from improperly set or parsed environment variables. Verify that your
DATABASE_URL
and other relevant environment variables are correctly configured in Railway, matching the format and values expected by Cal. -
Domain Matching Warning: Add your Railway app's domain to the
ALLOWED_HOSTNAMES
environment variable to resolve the domain matching warning. If your app's URL ishttps://cal-production-a4cb.up.railway.app
, include this in theALLOWED_HOSTNAMES
. -
Environment Variables: Double-check all required environment variables are set, including those for authentication, database connections, and any other services your deployment needs. For SSL connections with PostgreSQL, you might need to set
PGSSLMODE
tono-verify
. -
Database Migrations: Ensure you've run the necessary database migrations for Cal, as a mismatch between the database schema and the application's expectations can lead to errors.
Addressing these points should help resolve the issues you're encountering with your Railway deployment of Cal.
Details
Sources
- Railway deployment problem - crowdin
- [CAL-468] Deployments empty state
- .env.example
- deploy/README.md
- app.json
- apps/api/v1/lib/helpers/safeParseJSON.ts
- packages/features/test/orgDomains.test.ts
- packages/lib/constants.ts
- apps/web/pages/auth/login.tsx
- apps/web/test/lib/next-config.test.ts
- packages/features/ee/organizations/lib/orgDomains.ts
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
would love some help from the railway team
Looks like @brody192 owns the Cal template. Brody do you want to have a look to make sure that this works?
I’d bet it’s missing an envvar that was added or something
Alternatively, might be good for the Cal team to own the template itself. Got thousands of people on it so:
- You’d control the health of that experience/deployment
- You’d make $$$ for it
Thanks for the ping Cooper, Will be heading out on a trip with friends today and tomorrow, but will see what I can find out!
After deploying the template I set a ALLOWED_HOSTNAMES
variable to "${{RAILWAY_PUBLIC_DOMAIN}}"
(with the quotes) and without the scheme as the env.example file shows.
@calcom/web:start: 12:14:48:757 WARNorgDomains.ts Match of WEBAPP_URL with ALLOWED_HOSTNAME failed {
@calcom/web:start: WEBAPP_URL: 'https://cal-production-f5f0.up.railway.app';,
@calcom/web:start: ALLOWED_HOSTNAMES: [
@calcom/web:start: 'cal-production-f5f0.up.railway.app'
@calcom/web:start: ]
@calcom/web:start: }
I must be missing something because that hostname is definitely a match to the hostname in WEBAPP_URL
?
NEXT_PUBLIC_WEBAPP_URL
is set to https://${{RAILWAY_PUBLIC_DOMAIN}}
And for what it's worth, the Railway generated domain still opens and redirects to /auth/setup
without any error codes or white screens returned.