kinde-oss / kinde-auth-nextjs

Kinde NextJS SDK - authentication for server rendered apps
https://kinde.com/docs/developer-tools/nextjs-sdk/
MIT License
150 stars 20 forks source link

Bug: Edge deployment API Route Error #105

Closed quacksire closed 8 months ago

quacksire commented 9 months ago

Prerequisites

Describe the issue

When deployed to CF Pages via the @cloudflare/next-on-pages package, user requests to /api/auth/[kindeAuth] are not resolved correctly and show a "Internal Server Error"

This does not happen in development and seems to also affect Vercel deployments as well.

CF Pages Log: image

User Facing:

image image

Library URL

https://github.com/kinde-oss/kinde-auth-nextjs

Library version

2.0.13

Operating system(s)

macOS

Operating system version(s)

14.2 Beta (23C5030f)

Further environment details

No response

Reproducible test case URL

No response

Additional information

There are no changes to the library or any special changes to how this library is implemented.

The most recent docs have followed word for word and since the entire auth flow works on development, I can assume I set it up correctly

I can share my project on a person-by-person basis

peterphanouvong commented 9 months ago

If you're getting an invalid URL string error its most likely to do with building to URL to redirect to get authenticated. The URL is built from some env variables - so it might be worth double checking that the .env variables are being set

DaveOrDead commented 9 months ago

Hey @quacksire did @peterphanouvong's comment help to resolve this or do you still need some assistance?

quacksire commented 8 months ago

Sorry about the delay, getting back into the swing of things after the holidays.

I readjusted the env vars to the URL it was being deployed on as @peterphanouvong and I still ran into the same issue.

Still not sure I know what's happening, and I can give access to the repo if needed.

Here's my .env

image

Here's my implementation of Sign In:

image

Here's my NextConfig

image

Here's my package.json

image

Here's my Vercel build settings (default Next.js preset) image

peterphanouvong commented 8 months ago

Hey @quacksire, sorry you're still running into this issue - have you seen this video? https://www.youtube.com/watch?v=ZNuE7CkB6ck.

It may help with making sure that you have vercel set up with the correct .env variables for deployment

quacksire commented 8 months ago

Following the video's guide, it worked successfully.

It was my mistake, I did not add or update the environment variables on the deployment platform (Vercel, Cloudflare Pages, etc)

Even though I deployed it with the .env file, which is not recommended anyway, it was not picked up by the deployment and was ignored by KindeSDK until I added the environment variables to that deployment's project on Vercel/Cloudflare Pages.

The issue was infuriatingly simple, but I appreciate the help nonetheless.