ndom91 / briefkasten

📮 Self hosted bookmarking app
https://briefkastenhq.com
MIT License
879 stars 45 forks source link

Route /auth/signin returns a 500 error #52

Closed hrdlnk closed 9 months ago

hrdlnk commented 1 year ago

Describe the bug

Route /auth/signin returns a 500 error Local build returns the page correctly Sorry if this is an obvious one, I’m not familiar with Nextjs at all, just really curious about this app

Reproduction

https://briefkasten-error-auth-signin.vercel.app/

System Info

Vercel, node 16

Used Package Manager

npm

Validations

ndom91 commented 1 year ago

Hey thanks for the reproduction, but that doesn't help much unfortunately since its a server-side error.

Can you check your logs on the Vercel project and share anything you find?

Also have you changed any of the src/pages/api/auth/[..nextauth].js file contents? Which auth providers have you set up?

xXZaretXx commented 1 year ago

Hey, I'm getting the same error but with the docker build. I changed the database url, the port, nextauth url and secret. the pnpm command seems to work

nextjs@c22c863eae1d:/app$ pnpm db:push

> briefkasten@0.9.0 db:push /app
> npx prisma db push

Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "briefkasten", schema "public" at "postgres:5432"

The database is already in sync with the Prisma schema.

✔ Generated Prisma Client (4.8.1 | library) to ./node_modules/.pnpm/@prisma+client@4.8.1_prisma@4.8.1/node_modules/@prisma/client in 441ms

npm notice
npm notice New major version of npm available! 8.19.4 -> 9.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.8.1
npm notice Run npm install -g npm@9.8.1 to update!
npm notice

but all i can see is : Oops! The page you're looking for isn't here.

docker output:

Attaching to bk-app, bk-postgres
bk-postgres  |
bk-postgres  | PostgreSQL Database directory appears to contain a database; Skipping initialization
bk-postgres  |
bk-postgres  | 2023-08-31 09:33:33.377 UTC [1] LOG:  starting PostgreSQL 14.9 (Debian 14.9-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
bk-postgres  | 2023-08-31 09:33:33.378 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
bk-postgres  | 2023-08-31 09:33:33.378 UTC [1] LOG:  listening on IPv6 address "::", port 5432
bk-postgres  | 2023-08-31 09:33:33.387 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
bk-postgres  | 2023-08-31 09:33:33.397 UTC [27] LOG:  database system was shut down at 2023-08-31 09:25:57 UTC
bk-postgres  | 2023-08-31 09:33:33.416 UTC [1] LOG:  database system is ready to accept connections
bk-app       |
bk-app       | > briefkasten@0.9.0 start /app
bk-app       | > next start
bk-app       |
bk-app       | ready - started server on 0.0.0.0:3003, url: http://localhost:3003
bk-app       | warn  - Invalid next.config.js options detected:
bk-app       |   - The root value has an unexpected property, sentry, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, modularizeImports, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, skipMiddlewareUrlNormalize, skipTrailingSlashRedirect, staticPageGenerationTimeout, swcMinify, trailingSlash, transpilePackages, typescript, useFileSystemPublicRoutes, webpack).
bk-app       |
bk-app       | See more info here: https://nextjs.org/docs/messages/invalid-next-config
bk-app       | [DEPRECATED] zustand/context will be removed in the future version. Please use `import { createStore, useStore } from "zustand"` for context usage. See: https://github.com/pmndrs/zustand/discussions/1180
bk-app       | TypeError: Cannot convert undefined or null to object
bk-app       |     at Function.keys (<anonymous>)
bk-app       |     at Signin (/app/.next/server/pages/auth/signin.js:114:43)
bk-app       |     at Wc (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
bk-app       |     at Zc (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
bk-app       |     at Z (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
bk-app       |     at $c (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
bk-app       |     at bd (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
bk-app       |     at Z (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
bk-app       |     at Zc (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:74:209)
bk-app       |     at Z (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
bk-app       | TypeError: Cannot convert undefined or null to object
bk-app       |     at Function.keys (<anonymous>)
bk-app       |     at Signin (/app/.next/server/pages/auth/signin.js:114:43)
bk-app       |     at Wc (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:44)
bk-app       |     at Zc (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:253)
bk-app       |     at Z (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
bk-app       |     at $c (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
bk-app       |     at bd (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
bk-app       |     at Z (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
bk-app       |     at Zc (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:74:209)
bk-app       |     at Z (/app/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)

if you need something more information, i try to help

brian-n-millar commented 1 year ago

I have the exact same issue as @xXZaretXx and its infuriating as there's no reason to even be using Sentry spyware in a self-hosted app, the whole point of self-hosting is to not be sending stuff to the cloud.

ndom91 commented 12 months ago

Calling Sentry "spyware" is a bit intense.. But speaking of, it is only enabled / reporting on briefkastenhq.com hosts. Meaning it won't be sending anything for self-hosters and shoulnd't even load iirc..

ndom91 commented 12 months ago

The next.js config note in the logs regarding an unidentified config option sentry can be ignored. That's just saying its not a valid / 1st party next.js/vercel config option.

The actual issue seems to be around /app/.next/server/pages/auth/signin.js:114. I cna take a closer look later, don't have the time atm.

lukasbindreiter commented 11 months ago

Just ran into this same issue as well.

The error happens here:

const containsOauthProviders = Object.keys(providers).some((p) =>
    ['google', 'github', 'keycloak', 'authentik'].includes(p)
  )

because providers was null.

For me this was the case because I didn`t actually configure an Oauth provider yet (Briefkasten was the first time I heard about NextAuth.js, so was just tinkering around a bit).

I got it resolved then by creating a Github Oauth App and then setting GITHUB_ID and GITHUB_SECRET. But I guess configuring any of the other ones resolves this as well.

So as the actual fix for Briefkasten I'd suggest just a custom error message letting us know to set up an oauth provider.

ndom91 commented 9 months ago

Good idea, I've added a little piece of code to throw an error there to remind users to setup providers if none are found :+1: