-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Package: nextjsIssues related to the Sentry Nextjs SDKIssues related to the Sentry Nextjs SDK
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
7.82.0
Framework Version
No response
Link to Sentry event
https://autores.sentry.io/issues/4676163831/events/d4dbf6490ef14a9392b2e02880e667ac/
SDK Setup
Dependencies:
- next v13.4.5 (using the app dir)
- next-auth v4.23.1 (also tried with the latest version, didn't help)
- sentry v7.82.0
My middleware.ts file (in the root dir, not src):
import { getToken } from "next-auth/jwt"
import { withAuth } from "next-auth/middleware"
import { NextResponse } from "next/server"
export default withAuth(
async function middleware(req) {
const token = await getToken({ req })
const isAuth = !!token
// more auth logic, omitted
return NextResponse.redirect(new URL("/", req.url))
},
{
callbacks: {
async authorized() {
// This is a work-around for handling redirect on auth pages.
// We return true here so that the middleware function above
// is always called.
return true
},
},
}
)
// specify paths to be handled by this middleware
export const config = {
matcher: [ "/dashboard"],
}My SDK setup just uses the default values generated by the sentry setup wizard.
After installing sentry and running npm run dev, I get this error:
Attempted import error: 'withAuth' is not exported from 'next-auth/middleware' (imported as 'withAuth').
- error middleware.ts (5:0) @ <unknown>
- error (0 , next_auth_middleware__WEBPACK_IMPORTED_MODULE_2__.withAuth) is not a function
I reverted all the changes made by the sentry wizard and ran the dev server again, confirmed no issues.
Steps to Reproduce
- create a next app using
create-next-app - install next-auth and create a middleware.ts file in the root dir with the contents above
- install @sentry/nextjs and run the sentry setup wizard
- run
npm run dev
Expected Result
No errors when running the dev server
Actual Result
import error in middleware.ts:
Attempted import error: 'withAuth' is not exported from 'next-auth/middleware' (imported as 'withAuth').
- error middleware.ts (5:0) @ <unknown>
- error (0 , next_auth_middleware__WEBPACK_IMPORTED_MODULE_2__.withAuth) is not a function
chillardinho
Metadata
Metadata
Assignees
Labels
Package: nextjsIssues related to the Sentry Nextjs SDKIssues related to the Sentry Nextjs SDK
Projects
Status
No status