Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BetterAuth Middleware and Session errors #384

Open
Ale1x opened this issue Jan 3, 2025 · 3 comments
Open

BetterAuth Middleware and Session errors #384

Ale1x opened this issue Jan 3, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@Ale1x
Copy link

Ale1x commented Jan 3, 2025

Describe the bug
I followed the guide in the next-forge docs then i'm getting the following errors

next-forge version
3.0.9 (latest)

To Reproduce
Steps to reproduce the behavior:

  1. Follow guide on how to switch from clerk to betterauth

Expected behavior
Error not happening

Screenshots
{A662EF0F-4529-43D4-98B3-0245D0419ED0}
{6BCE23DF-B6D6-4F2D-8F6E-950DBA002BAF}

Desktop (please complete the following information):

  • OS: Windows 11 PRO 24H2
  • Browser: brave 1.73.104
@Ale1x Ale1x added the bug Something isn't working label Jan 3, 2025
@haydenbleasel
Copy link
Owner

@Ale1x Possibly resolved in the fix for #386. Would you be able to verify for me by checking out the latest migration docs?

@mikestecker
Copy link

I'm seeing a number of other errors as well. This is with the latest from the docs

  ⨯ [Error: The Middleware "/middleware" must export a `middleware` or a `default` function]
│ TypeError: Cannot read properties of undefined (reading 'origin')
│     at authMiddleware (packages/auth/middleware.ts:9:63)
│     at <unknown> (apps/web/middleware.ts:22:30)
│    7 |
│    8 | export const authMiddleware = async (request: NextRequest) => {
│ >  9 |   const url = new URL('/api/auth/get-session', request.nextUrl.origin);
│      |                                                               ^
│   10 |   const response = await fetch(url, {
│   11 |     headers: {
│   12 |       cookie: request.headers.get('cookie') || '',
│  ⨯ unhandledRejection: TypeError: Cannot read properties of undefined (reading 'origin')
│     at authMiddleware (packages/auth/middleware.ts:9:63)
│     at <unknown> (apps/web/middleware.ts:22:30)
│    7 |
│    8 | export const authMiddleware = async (request: NextRequest) => {
│ >  9 |   const url = new URL('/api/auth/get-session', request.nextUrl.origin);
│      |                                                               ^
│   10 |   const response = await fetch(url, {
│   11 |     headers: {
│   12 |       cookie: request.headers.get('cookie') || '',
│  ⨯ unhandledRejection:  TypeError: Cannot read properties of undefined (reading 'origin')
│     at authMiddleware (packages/auth/middleware.ts:9:63)
│     at <unknown> (apps/web/middleware.ts:22:30)
│    7 |
│    8 | export const authMiddleware = async (request: NextRequest) => {
│ >  9 |   const url = new URL('/api/auth/get-session', request.nextUrl.origin);
│      |                                                               ^
│   10 |   const response = await fetch(url, {
│   11 |     headers: {
│   12 |       cookie: request.headers.get('cookie') || '',

@mikestecker
Copy link

Screenshot 2025-01-06 at 6 50 45 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants