[Error: Failed to collect page data for /api/auth/[...all]] coolify

I building my next.js app on coolify with nixpack but i get this error . [Error: Failed to collect page data for /api/auth/[...all]] what i can do ? @bekacru @Max
40 Replies
nikatune
nikatuneOP2mo ago
@Alex Yang
Alex Yang
Alex Yang2mo ago
are there more logs?
nikatune
nikatuneOP2mo ago
yeah sec my versions btw : "better-auth": "^1.3.6", "next": "15.3.5",
nikatune
nikatuneOP2mo ago




nikatune
nikatuneOP2mo ago
here you go @Alex Yang TypeError: Cannot read properties of undefined (reading 'promise')
Alex Yang
Alex Yang2mo ago
have you try to bump the version? both of them?
nikatune
nikatuneOP2mo ago
wdym? next or ba? i upgraded to 1.3.9 but still same @Alex Yang anything?
Alex Yang
Alex Yang2mo ago
yeah I mean bump both nextjs and better-auth what's your config? can you run npx @better-auth/cli info --json
nikatune
nikatuneOP2mo ago
yeah
{
"system": {
"platform": "win32",
"arch": "x64",
"version": "Windows 11 Pro",
"release": "10.0.26100",
"cpuCount": 12,
"cpuModel": "AMD Ryzen 5 5600X 6-Core Processor ",
"totalMemory": "31.94 GB",
"freeMemory": "16.01 GB"
},
"node": {
"version": "v22.14.0",
"env": "development"
},
"packageManager": {
"name": "npm",
"version": "11.1.0"
},
"frameworks": [
{
"name": "next",
"version": "15.3.5"
},
{
"name": "react",
"version": "^18.3.1"
}
],
"databases": [
{
"name": "mysql2",
"version": "^3.14.3"
},
{
"name": "drizzle",
"version": "^0.44.4"
}
],
"betterAuth": {
"version": "0.1.0",
"config": {
"appName": "Ozkan Oto",
"emailAndPassword": {
"enabled": true,
"autoSignIn": true
},
"plugins": [
{
"name": "admin",
"config": {
"id": "admin",
"hooks": {
"after": [
{}
]
},
"endpoints": {},
"$ERROR_CODES": {
"FAILED_TO_CREATE_USER": "Failed to create user",
"USER_ALREADY_EXISTS": "User already exists. Use another email.",
"YOU_CANNOT_BAN_YOURSELF": "You cannot ban yourself",
"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE": "You are not allowed to change users role",
"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS": "You are not allowed to create users",
"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS": "You are not allowed to list users",
"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS": "You are not allowed to list users sessions",
"YOU_ARE_NOT_ALLOWED_TO_BAN_USERS": "You are not allowed to ban users",
"YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS": "You are not allowed to impersonate users",
"YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS": "You are not allowed to revoke users sessions",
"YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS": "You are not allowed to delete users",
"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD": "[REDACTED]",
"BANNED_USER": "You have been banned from this application",
"YOU_ARE_NOT_ALLOWED_TO_GET_USER": "You are not allowed to get user",
"NO_DATA_TO_UPDATE": "No data to update",
"YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS": "You are not allowed to update users",
"YOU_CANNOT_REMOVE_YOURSELF": "You cannot remove yourself"
},
"schema": {
"user": {
"fields": {
"role": {
"type": "string",
"required": false,
"input": false
},
"banned": {
"type": "boolean",
"defaultValue": false,
"required": false,
"input": false
},
"banReason": {
"type": "string",
"required": false,
"input": false
},
"banExpires": {
"type": "date",
"required": false,
"input": false
}
}
},
"session": {
"fields": {
"impersonatedBy": {
"type": "string",
"required": false
}
}
}
}
}
}
]
}
}
}
{
"system": {
"platform": "win32",
"arch": "x64",
"version": "Windows 11 Pro",
"release": "10.0.26100",
"cpuCount": 12,
"cpuModel": "AMD Ryzen 5 5600X 6-Core Processor ",
"totalMemory": "31.94 GB",
"freeMemory": "16.01 GB"
},
"node": {
"version": "v22.14.0",
"env": "development"
},
"packageManager": {
"name": "npm",
"version": "11.1.0"
},
"frameworks": [
{
"name": "next",
"version": "15.3.5"
},
{
"name": "react",
"version": "^18.3.1"
}
],
"databases": [
{
"name": "mysql2",
"version": "^3.14.3"
},
{
"name": "drizzle",
"version": "^0.44.4"
}
],
"betterAuth": {
"version": "0.1.0",
"config": {
"appName": "Ozkan Oto",
"emailAndPassword": {
"enabled": true,
"autoSignIn": true
},
"plugins": [
{
"name": "admin",
"config": {
"id": "admin",
"hooks": {
"after": [
{}
]
},
"endpoints": {},
"$ERROR_CODES": {
"FAILED_TO_CREATE_USER": "Failed to create user",
"USER_ALREADY_EXISTS": "User already exists. Use another email.",
"YOU_CANNOT_BAN_YOURSELF": "You cannot ban yourself",
"YOU_ARE_NOT_ALLOWED_TO_CHANGE_USERS_ROLE": "You are not allowed to change users role",
"YOU_ARE_NOT_ALLOWED_TO_CREATE_USERS": "You are not allowed to create users",
"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS": "You are not allowed to list users",
"YOU_ARE_NOT_ALLOWED_TO_LIST_USERS_SESSIONS": "You are not allowed to list users sessions",
"YOU_ARE_NOT_ALLOWED_TO_BAN_USERS": "You are not allowed to ban users",
"YOU_ARE_NOT_ALLOWED_TO_IMPERSONATE_USERS": "You are not allowed to impersonate users",
"YOU_ARE_NOT_ALLOWED_TO_REVOKE_USERS_SESSIONS": "You are not allowed to revoke users sessions",
"YOU_ARE_NOT_ALLOWED_TO_DELETE_USERS": "You are not allowed to delete users",
"YOU_ARE_NOT_ALLOWED_TO_SET_USERS_PASSWORD": "[REDACTED]",
"BANNED_USER": "You have been banned from this application",
"YOU_ARE_NOT_ALLOWED_TO_GET_USER": "You are not allowed to get user",
"NO_DATA_TO_UPDATE": "No data to update",
"YOU_ARE_NOT_ALLOWED_TO_UPDATE_USERS": "You are not allowed to update users",
"YOU_CANNOT_REMOVE_YOURSELF": "You cannot remove yourself"
},
"schema": {
"user": {
"fields": {
"role": {
"type": "string",
"required": false,
"input": false
},
"banned": {
"type": "boolean",
"defaultValue": false,
"required": false,
"input": false
},
"banReason": {
"type": "string",
"required": false,
"input": false
},
"banExpires": {
"type": "date",
"required": false,
"input": false
}
}
},
"session": {
"fields": {
"impersonatedBy": {
"type": "string",
"required": false
}
}
}
}
}
}
]
}
}
}
@Alex Yang here
Alex Yang
Alex Yang2mo ago
I might take a look after dinner. But if you can provide a reproduce code and I can debug it quicker
nikatune
nikatuneOP2mo ago
i have no idea i cant host it on coolify with nixpack i can build it vercel and locally it works fine
Alex Yang
Alex Yang2mo ago
feels like it related to the deps. you need find out which code call promise maybe try bump nextjs to latest, or even canary
nikatune
nikatuneOP2mo ago
im sure not because of this @bekacru can you look at to this? you can solve it its important
bekacru
bekacru2mo ago
you're trying to build a page that requires auth as a static page
nikatune
nikatuneOP2mo ago
so what i need to do for fix it? @Max anything?
bekacru
bekacru2mo ago
basically find a page you're calling authClient with, that'll end up being served us a static page and force it to be dynamic or move some of the parts to a client component or something similar.
nikatune
nikatuneOP2mo ago
i removed my all authClient and auth.api calls on pages but its still same im not even using authClient right now @Max here
bekacru
bekacru2mo ago
oh even on compoenents make sure those components don't get rendered as a static page
nikatune
nikatuneOP2mo ago
im so confused because i can build it locally and build it on vercel but i cant do it with Nixpack or Dockerfile on coolify i tried to update Next and BA version but it didnt go well too So i need to make them all dynamic pages? page.tsx -> export default async function Test() { return <ClientComponent /> } or export const dynamic = "force-dynamic";
bekacru
bekacru2mo ago
where you're using authClient yes since on build time auth client won't be able to make api requets
nikatune
nikatuneOP2mo ago
but right now im not using authClient anywhere because i deleted them for testing, i created a new branch on git but still same error anything ? @Max i still cant deploy my app
Ping
Ping2mo ago
So your not using Better-auth anywhere in your UI, but it won't build in your hosting provider?
nikatune
nikatuneOP2mo ago
im only using auth.api on api routes, not using on client side right now but still cant build it building with NixPacks on coolify "better-auth": "^1.3.6", "next": "15.3.5", no idea why it happeing
Ping
Ping2mo ago
So you think something in better-auth is causing this?
nikatune
nikatuneOP2mo ago
#13 24.37 TypeError: Cannot read properties of undefined (reading 'promise') #13 24.40 [Error: Failed to collect page data for /api/auth/[...all]] { isnt it better auth error? . full build logs
#13 24.37 TypeError: Cannot read properties of undefined (reading 'promise')
2025-Sep-12 22:07:05.656353
#13 24.37 at eD (.next/server/chunks/3671.js:8:36133)
2025-Sep-12 22:07:05.656353
#13 24.37 at eh (.next/server/chunks/3671.js:8:36900)
2025-Sep-12 22:07:05.656353
#13 24.37 at 96157 (.next/server/chunks/4667.js:1:15923)
2025-Sep-12 22:07:05.656353
#13 24.37 at t (.next/server/webpack-runtime.js:1:128)
2025-Sep-12 22:07:05.656353
#13 24.37 at 41098 (.next/server/app/api/auth/[...all]/route.js:1:721)
2025-Sep-12 22:07:05.656353
#13 24.37 at t (.next/server/webpack-runtime.js:1:128)
2025-Sep-12 22:07:05.656353
#13 24.37 at 42847 (.next/server/app/api/auth/[...all]/route.js:1:1174)
2025-Sep-12 22:07:05.656353
#13 24.37 at t (.next/server/webpack-runtime.js:1:128)
2025-Sep-12 22:07:05.656353
#13 24.37 at t (.next/server/app/api/auth/[...all]/route.js:1:4143)
2025-Sep-12 22:07:05.656353
#13 24.37 at <unknown> (.next/server/app/api/auth/[...all]/route.js:1:4186)
#13 24.37 TypeError: Cannot read properties of undefined (reading 'promise')
2025-Sep-12 22:07:05.656353
#13 24.37 at eD (.next/server/chunks/3671.js:8:36133)
2025-Sep-12 22:07:05.656353
#13 24.37 at eh (.next/server/chunks/3671.js:8:36900)
2025-Sep-12 22:07:05.656353
#13 24.37 at 96157 (.next/server/chunks/4667.js:1:15923)
2025-Sep-12 22:07:05.656353
#13 24.37 at t (.next/server/webpack-runtime.js:1:128)
2025-Sep-12 22:07:05.656353
#13 24.37 at 41098 (.next/server/app/api/auth/[...all]/route.js:1:721)
2025-Sep-12 22:07:05.656353
#13 24.37 at t (.next/server/webpack-runtime.js:1:128)
2025-Sep-12 22:07:05.656353
#13 24.37 at 42847 (.next/server/app/api/auth/[...all]/route.js:1:1174)
2025-Sep-12 22:07:05.656353
#13 24.37 at t (.next/server/webpack-runtime.js:1:128)
2025-Sep-12 22:07:05.656353
#13 24.37 at t (.next/server/app/api/auth/[...all]/route.js:1:4143)
2025-Sep-12 22:07:05.656353
#13 24.37 at <unknown> (.next/server/app/api/auth/[...all]/route.js:1:4186)
Ping
Ping2mo ago
Can you show me what you have in route.ts? I assume you just copied from our docs right
nikatune
nikatuneOP2mo ago
yeah im literally just using this
const session = await auth.api.getSession({headers: await headers())
const session = await auth.api.getSession({headers: await headers())
nothing more
nikatune
nikatuneOP2mo ago
No description
nikatune
nikatuneOP2mo ago
all routes works good
Ping
Ping2mo ago
no i mean in app/api/auth/[...all]/route.js
nikatune
nikatuneOP2mo ago
nothing
nikatune
nikatuneOP2mo ago
No description
Ping
Ping2mo ago
yeah that looks fine & normal, it doesn't make sense that build would fail and caused by that file Building on local & vercel works for you too, are you sure you don't have some special configuration or anything on coolify or with nixpacks causing this?
nikatune
nikatuneOP2mo ago
no literally zero config other next apps works good ( without BA ) it runs npm run build
Ping
Ping2mo ago
Can you make a minimal repro?
nikatune
nikatuneOP2mo ago
No description
nikatune
nikatuneOP2mo ago
No description
nikatune
nikatuneOP2mo ago
wdym?
Ping
Ping2mo ago
Make a simple version of your app that makes that error in a github repo so that we can run the code ourselves and see if we can solve it
nikatune
nikatuneOP2mo ago
i can give you perms in repo if you want whats ur email?

Did you find this page helpful?