Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keystatic is unable to find environment variables when deployed with Vercel #1379

Closed
anieve01 opened this issue Dec 11, 2024 · 1 comment
Closed

Comments

@anieve01
Copy link

I have a similar to this: #1229
when NEXT_PUBLIC_KEYSTATIC_STORAGE_KIND = github
even though I've added KEYSTATIC_GITHUB_CLIENT_ID, KEYSTATIC_GITHUB_CLIENT_SECRET and KEYSTATIC_SECRET to the environment variables in vercel settings, the build on vercel fails with the following error:

[22:09:39.260] web:build: Error: Missing required config in Keystatic API setup when using the 'github' storage mode:
[22:09:39.260] web:build: - clientId (can be provided via KEYSTATIC_GITHUB_CLIENT_ID env var)
[22:09:39.264] web:build: - clientSecret (can be provided via KEYSTATIC_GITHUB_CLIENT_SECRET env var)
[22:09:39.264] web:build: - secret (can be provided via KEYSTATIC_SECRET env var)
[22:09:39.264] web:build: 
[22:09:39.264] web:build: If you've created your GitHub app locally, make sure to copy the environment variables from your local env file to your deployed environment
[22:09:39.265] web:build:     at t.slugEnvName (/vercel/path0/apps/web/.next/server/app/api/keystatic/[...params]/route.js:2:4364)
[22:09:39.265] web:build:     at <unknown> (/vercel/path0/apps/web/.next/server/app/api/keystatic/[...params]/route.js:5:929)
[22:09:39.265] web:build:     at 46025 (/vercel/path0/apps/web/.next/server/app/api/keystatic/[...params]/route.js:5:1216)
[22:09:39.265] web:build:     at t (/vercel/path0/apps/web/.next/server/webpack-runtime.js:1:143)
[22:09:39.267] web:build:     at r (/vercel/path0/apps/web/.next/server/app/api/keystatic/[...params]/route.js:5:10929)
[22:09:39.267] web:build:     at <unknown> (/vercel/path0/apps/web/.next/server/app/api/keystatic/[...params]/route.js:5:10967)
[22:09:39.267] web:build:     at t.X (/vercel/path0/apps/web/.next/server/webpack-runtime.js:1:1291)
[22:09:39.267] web:build:     at <unknown> (/vercel/path0/apps/web/.next/server/app/api/keystatic/[...params]/route.js:5:10942)
[22:09:39.267] web:build:     at Object.<anonymous> (/vercel/path0/apps/web/.next/server/app/api/keystatic/[...params]/route.js:5:10995)
[22:09:39.267] web:build: 
[22:09:39.267] web:build: > Build error occurred
[22:09:39.275] web:build: Error: Failed to collect page data for /api/keystatic/[...params]
[22:09:39.275] web:build:     at <unknown> (/vercel/path0/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]_nyrugx3rio3z6lftbbvibuxvju/node_modules/next/dist/build/utils.js:1234:15) {
[22:09:39.275] web:build:   type: 'Error'
[22:09:39.275] web:build: }
[22:09:39.299] web:build:  ELIFECYCLE  Command failed with exit code 1.
[22:09:39.316] web:build:  ELIFECYCLE  Command failed with exit code 1.
[22:09:39.330] web:build: ERROR: command finished with error: command (/vercel/path0/apps/web) /pnpm9/node_modules/.bin/pnpm run build exited (1)
[22:09:39.330] web#build: command (/vercel/path0/apps/web) /pnpm9/node_modules/.bin/pnpm run build exited (1)
[22:09:39.330] 
[22:09:39.331]  WARNING  finished with warnings
[22:09:39.331] 
[22:09:39.331] Warning - the following environment variables are set on your Vercel project, but missing from "turbo.json". These variables WILL NOT be available to your application and may cause your build to fail. Learn more at https://turbo.build/repo/docs/platform-environment-variables
[22:09:39.331] 
[22:09:39.331] [warn] web#build
[22:09:39.331] [warn]   - KEYSTATIC_GITHUB_CLIENT_ID 
[22:09:39.331] [warn]   - KEYSTATIC_GITHUB_CLIENT_SECRET 
[22:09:39.331] [warn]   - KEYSTATIC_SECRET 
[22:09:39.333] 
[22:09:39.333]   Tasks:    0 successful, 1 total
[22:09:39.333]  Cached:    0 cached, 1 total
[22:09:39.333]    Time:    1m27.781s 
[22:09:39.333] Summary:    /vercel/path0/.turbo/runs/2q3M07rpDC5Qv6Ko19XbjtWCThX.json
[22:09:39.333]  Failed:    web#build
[22:09:39.333] 
[22:09:39.339]  ERROR  run failed: command  exited (1)
[22:09:39.353] Error: Command "turbo run build" exited with 1
[22:09:40.290] 

I'm using pnpm and vercel turborepo in my deploy.
node 20
"@keystatic/core": "0.5.41",
"@keystatic/next": "^5.0.1",
"@markdoc/markdoc": "^0.4.0"

The only thing that works is storage kind = local; haven't tried cloud

@anieve01
Copy link
Author

Resolved the issue; problem was my fault. I needed to also add the keystatic environment variables to globalEnv in turbo.json.
Also, I was missing these env vars:
NEXT_PUBLIC_KEYSTATIC_CONTENT_PATH
KEYSTATIC_GITHUB_TOKEN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant