Trouble deploying next.js monorep

rhymiz
PRO

6 months ago

New to using Railway and having a little bit of trouble deploying a monorepo next.js app.

I've got all the environment variables setup, but somehow whenever I try to access the service, I see an error related to environment variables not being found.

Here is a snippet of the error:

sandwich-club:start: Error: @clerk/nextjs: Missing secretKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.

sandwich-club:start: at Object.throwMissingSecretKeyError (/app/apps/www/.next/server/src/middleware.js:20:1695)

sandwich-club:start: at /app/apps/www/.next/server/src/middleware.js:45:5405

sandwich-club:start: at /app/apps/www/.next/server/src/middleware.js:45:5375

sandwich-club:start: at /app/apps/www/.next/server/src/middleware.js:45:5381

sandwich-club:start: at Object.<anonymous> (/app/apps/www/.next/server/src/middleware.js:27:16317)

sandwich-club:start: at t.mechanism.type (/app/apps/www/.next/server/src/middleware.js:13:37171)

sandwich-club:start: at te (/app/apps/www/.next/server/src/middleware.js:13:26087)

sandwich-club:start: at /app/apps/www/.next/server/src/middleware.js:13:37162

sandwich-club:start: at te.status (/app/apps/www/.next/server/src/middleware.js:13:36883)

sandwich-club:start: at te (/app/apps/www/.next/server/src/middleware.js:13:26087)

sandwich-club:start: Error [ERR_HTTP_HEADERS_SENT]: Cannot append headers after they are sent to the client

sandwich-club:start: at ServerResponse.appendHeader (node:_http_outgoing:759:11)

sandwich-club:start: at /app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:24551

sandwich-club:start: at _Headers.forEach (node:internal/deps/undici/undici:4351:26)

sandwich-club:start: at m (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:24533)

sandwich-club:start: at P (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:83072)

sandwich-club:start: at nq (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:69672)

sandwich-club:start: at n1 (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:81755)

sandwich-club:start: at AsyncLocalStorage.run (node:async_hooks:346:14)

sandwich-club:start: at Timeout._onTimeout (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:87775)

sandwich-club:start: at listOnTimeout (node:internal/timers:573:17) {

sandwich-club:start: code: 'ERR_HTTP_HEADERS_SENT',

sandwich-club:start: digest: '2796197038'

sandwich-club:start: }

Solved

3 Replies

rhymiz
PRO

6 months ago

To clarify further - I know the environment variables I've provided are working because the build process depends on env variables being present for static page generation. The issue only presents itself after the container has started - which means environment variables are likely not being injected into the container


unicodeveloper
PRO

6 months ago

Hi, I am checking your error logs and that's not the error I see here.

9.572 Error: ENOENT: no such file or directory, stat '/app/node_modules/@prisma/engines/schema-engine-debian-openssl-3.0.x'

Dec 20 19:19:39

9.572 error: script "db:generate" exited with code 1

this is where it fails. So are we on the same page or are you referring to something else?


Status changed to Awaiting User Response railway[bot] 6 months ago


unicodeveloper

Hi, I am checking your error logs and that's not the error I see here.9.572 Error: ENOENT: no such file or directory, stat '/app/node_modules/@prisma/engines/schema-engine-debian-openssl-3.0.x'Dec 20 19:19:399.572 error: script "db:generate" exited with code 1this is where it fails. So are we on the same page or are you referring to something else?

rhymiz
PRO

6 months ago

Thanks for taking the time to respond. I think that was a red herring. I got my issue resolved - I was missing a key in my turbo.json configuration


Status changed to Awaiting Railway Response railway[bot] 6 months ago


Status changed to Solved brody 6 months ago