sambecker / exif-photo-blog

Photo blog, reporting 🤓 EXIF camera details (aperture, shutter speed, ISO) for each image.
https://photos.sambecker.com
685 stars 108 forks source link

500 error on login #41

Closed mintmatica closed 7 months ago

mintmatica commented 7 months ago

Any idea why im getting a 500 server error when trying to log in? All I did was add some SEO items and push to my main domain.

What super weird is that if I try to login on a vercel domain, everything works fine. this url works: https://pantaleone-bnn51uosa-my-team-98901580.vercel.app/admin

This URL does not and throws the errors: https://pantaleone.net/admin

Pulling my hair out on this, but I have been using the vercel domain as my "admin domain"....

Image 1-13-24 at 7 07 PM

sambecker commented 7 months ago

What SEO items did you add?

Can you track down the actual error in Vercel logs?

mintmatica commented 7 months ago

im going to back out all my updates. what's odd, is im getting the same exact thing if i try logging into your admin page. I obviously dont have the login/pass, but this is exactly what im seeing.

Its like the callback URL cant be found for some reason....

Matt

Image 1-14-24 at 11 30 AM

sambecker commented 7 months ago

Very interesting. I was able to log in and out my site just now without issue. However we did have a regression at some point where we stopped properly catching the auth error necessary to tell the user their login/password is wrong. This was fixed but may have regressed again.

Can you verify that all auth environment variables are available in production? I believe there's 3, and a 4th meant only for development.

mintmatica commented 7 months ago

I dont think its due to incorrect login/pass. When I enter the correct credentials, immediately, it throws the 500 error and white screen. This did start occurring in the last couple of days. Ill try to back out my changes in the meantime and see if that helps.

Here are all my current vercel environment variables: env variables pnet.pdf

sambecker commented 7 months ago

Try having your Vercel logs open when you sign in. You might see more info, like a "credential" error, at the time you see a 500.

Regarding environment variables, is there a reason you have both AUTH_SECRET and NEXT_AUTH_SECRET?

mintmatica commented 7 months ago

added both, just to see if that could fix the issue. Again, im not an experienced dev over here :).

mintmatica commented 7 months ago

I wonder if this is a DNS issue - Im able to log in via Vercel no problem to the same deployment thats on the vercel.app domain. Super odd.

sambecker commented 7 months ago

Very interesting. That is possible. Are you sure the custom domain version works over HTTPS? And that it points to the same deployment as the vercel.app version?

mintmatica commented 7 months ago

correct, i just tested a couple times. screenshot below.

When trying to login:

pantaleone.net - doesnt work Second link (vercel) - works Third link (vercel) - works

I did just change my DNS last night from Hostinger to Vercel. will investigate more in the AM and report back.

Matt

image

sambecker commented 7 months ago

OK—that leads me to lean toward it being DNS-related as well.

In the meantime, you might want to try syncing your fork. I posted a couple commits tonight that might help you debug.

mintmatica commented 7 months ago

This continues to be a super weird one. Here are the various troubleshooting steps i've done without success. As a reminder, my main domain - pantaleone.net - will not let me log into /admin. I AM able to login on vercel.app domains.

Troubleshooting steps performed:

Im going to try a couple more things with my old webhost, Hostinger to see if its on their side.

Let me know if you have any other thoughts, else, I'll report back.

Cheers, Matt

Image 1-16-24 at 7 15 PM

sambecker commented 7 months ago

What's the content for all four of those POST errors (in some cases it may be beneath your screenshot on the lower right)?

Can you confirm you're using the latest code from main?

If you diff your app from main does anything auth-related pop up?

Some DNS questions: who's your DNS host? are you using a service like Cloudflare which might intercept/proxy traffic? Is www.pantaleone.net your primary domain or is it just pantaleone.net without the www? Might your DNS service forward root traffic to www traffic or vice versa?

mintmatica commented 7 months ago

heres the second log:

Image 1-16-24 at 7 53 PM

3rd:

Image 1-16-24 at 7 55 PM

4th (I also pasted the full log below)

Image 1-16-24 at 7 56 PM

d: Read more at https://errors.authjs.dev#credentialssignin at Object.l (/var/task/.next/server/chunks/4692.js:6:101883) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async c (/var/task/.next/server/chunks/4692.js:6:115329) at async c (/var/task/.next/server/chunks/4692.js:6:94922) at async s (/var/task/.next/server/chunks/4692.js:340:58128) at async i (/var/task/.next/server/chunks/5438.js:1:1953) at async /var/task/nodemodules/.pnpm/next@14.0.4@babel+core@7.23.7_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:406 at async rm (/var/task/nodemodules/.pnpm/next@14.0.4@babel+core@7.23.7_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:5703) at async rD (/var/task/nodemodules/.pnpm/next@14.0.4@babel+core@7.23.7_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:22546) at async J (/var/task/nodemodules/.pnpm/next@14.0.4@babel+core@7.23.7_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:25253) { type: 'CredentialsSignin', kind: 'signIn' }

mintmatica commented 7 months ago

on your other ?'s:

Not using the latest code from main, thats the next step

If you diff your app from main does anything auth-related pop up? - Not sure, but all the logs appear to be auth related.

On DNS - I pointed everything to Vercel on Saturday except the name servers on accident. I just pointed the name servers over.

Image 1-16-24 at 8 06 PM

mintmatica commented 7 months ago

oh, and on the 'www' non www - i just followed Vercels reco when adding a domain. Im not directing traffic elsewhere.

sambecker commented 7 months ago

I see CredentialsSignin at the top of one of your logs which is most likely an email/password mismatch. If there's a safe way to do it, I would make sure your ENV vars match your email/password credentials. I wonder if it's a case of those environment variables landing in different domains linked to different environments? Might those differ in Production vs Preview?

sambecker commented 7 months ago

The latest auth code does a better job catching that particular error—make sure you're running the latest. If so, and there's a CredentialsSignin exception, you should no longer have a server crash but rather a red note presented like this:

CleanShot 2024-01-16 at 21 13 54@2x

sambecker commented 7 months ago

You could also carefully add some server-side logging in src/auth/index.ts to make sure your email/password checks are comparing the right values:

CleanShot 2024-01-16 at 22 13 58@2x

sambecker commented 7 months ago

Closing for now. Let me know if you discover anything else that could help us debug.