Closed OpenTextASOWSM closed 6 months ago
Related to Pull request with fix - https://github.com/nextauthjs/next-auth/pull/10283
moving to pull request https://github.com/nextauthjs/next-auth/pull/10304 as prior was on an branch, not merged to main.
https://github.com/nextauthjs/next-auth/pull/10304 is waiting for reviewer
Any update about this pr? I can not use the auth() in getServerSideProps function because of that.
NextJs version: 14.2.2 NextAuth version: 5.0.0-beta.16
These file changes seems fine. I tried on my local and finally I can use auth() in getServerSideProps function.
node_modules/next-auth/lib/actions.js From: Line 2 import { headers as nextHeaders, cookies } from "next/headers"; Line 3 import { redirect } from "next/navigation";
To: Line 2 import { headers as nextHeaders, cookies } from "next/headers.js"; Line 3 import { redirect } from "next/navigation.js";
node_modules/next-auth/lib/index.js From: Line 3 import { headers } from "next/headers"; Line 4 import { NextResponse } from "next/server";
To: Line 3 import { headers } from "next/headers.js"; Line 4 import { NextResponse } from "next/server.js";
node_modules/next-auth/lib/env.js From: Line 1 import { NextRequest } from "next/server";
To: Line 1 import { NextRequest } from "next/server.js";
As @OpenTextASOWSM said, the changes in this pr (#10304 ) seem to solve the problem. It deserves at least a review.
Here i got the error: Did you mean to import "next/server.js"..
I saw that the commit was closed (https://github.com/nextauthjs/next-auth/pull/10304), is there any workaround to make it work?
Seems they think root cause is in next.js not next-auth so aren't taking these fixes as work around. There is more commentary here: https://github.com/nextauthjs/next-auth/discussions/9385
Environment
Reproduction URL
https://github.com/OpenTextASOWSM/authjs-nextauth-5beta-repro
Describe the issue
Following the Authjs.dev Oauth tutorial witht he current npm next-auth/@beta adding it to an existing project I got errors:
Error:
Cause:
Seems to be mixed .js and .ts in libraries and some people have issues with locating correct files. See other places in auth.js core libraries where .js is added to explicitly select the right files, probably due to the same issue. Resolution: I made changes locally in my node_modules to temporarily resolve this.
node_modules/next-auth/lib/env.js
-from-
node_modules/next-auth/lib/index.js
-to-node_modules/next-auth/lib/actions.js
-to-
after making changes restarting npm run dev I was able to use the sample code
How to reproduce
reproduction adding to an existing project not using the sample next-auth collection and using tutorials.
Expected behavior
Runs without throwing the error as it can identify files to include no matter if it has a .js or .ts extension