Comments (12)
@timneutkens using webpack, i continue to see the same issue:
from next.js.
This just began happening to me as well after upgrading to next@15 RC and adding middleware. I am not creating a context within the middleware. My context is in a client component with 'use client' at the top of the file. Everything was working fine, and still does, unless I add middleware.ts to the root of my src/ directory.
from next.js.
I'm having the same issue
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!
from next.js.
In my project, the issue appears with Webpack using next-intl
from next.js.
the same issue
from next.js.
Please open a new issue with a reproduction. It's expected that createContext is not available in middleware / route handlers, they're bundled in the same way as server components nowadays to ensure that things like client-only
/ server-only
work correctly.
from next.js.
For me, it appears this is an issue with AuthJS v5. If I remove authJS and throw in the middleware example found in the next docs (see below), the createContext is not a function log no longer appears.
My middleware without AuthJS (no error)
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
// This function can be marked `async` if using `await` inside
export function middleware(request: NextRequest) {
return NextResponse.redirect(new URL('/sign-in', request.url))
}
// See "Matching Paths" below to learn more
export const config = {
matcher: [
'/dashboard/',
'/account/:path*',
'/dashboard/:path*',
'/memberships/:path*',
'/api/v2/:path*',
],
}
My middlewar with AuthJS (error)
export { auth as middleware } from '~/server/auth'
// See "Matching Paths" below to learn more
export const config = {
matcher: [
'/dashboard/',
'/account/:path*',
'/dashboard/:path*',
'/memberships/:path*',
'/api/v2/:path*',
],
}
from next.js.
Please open a new issue with a reproduction. It's expected that createContext is not available in middleware / route handlers, they're bundled in the same way as server components nowadays to ensure that things like
client-only
/server-only
work correctly.
I can observe that i was using a dependency on the middleware that was using react context. removing that dependency made it working again Thanks
from next.js.
How to solve it in the end?
from next.js.
my issue is with authjs v5 as well, any workaround?
from next.js.
@liuhuapiaoyuan @kyb3r The latest canary version should resolved this. Fixed in https://github.com/vercel/next.js/releases/tag/v14.3.0-canary.81 to be specific.
from next.js.
As said above: please open a new issue with a reproduction.
Then we can have a look 🙂
from next.js.
Related Issues (20)
- Github actions: Error: Page "/logs/publish/[id]" is missing "generateStaticParams()" so it cannot be used with "output: export" config. HOT 1
- Next 14 shows flicker with external React Native components on web
- Preflight cache middleware opt-out not working for rewrite of dynamic routes
- [Turbopack] [Next 15 RC] Cannot resolve exported paths from `@skeletonlabs/skeleton@next` HOT 2
- redirect in NextJS config doesn't populate param in `destination` more than once
- The Edge Function "middleware" size is 1.01 MB and your plan size limit is 1 MB. Though the file is 173kb HOT 4
- Subresource Integrity (SRI) not working HOT 1
- global-error.tsx doesn't work next.js 14+
- [Next 15 RC] create-next-app --empty with tw and src dir has wrong content path HOT 3
- CORS middleware not applied to preview and staging domains, but works on production domain
- From my testing, when GET and PUT are the only methods set, it breaks. I also tried changing the order in which they are set.
- Request method bug in production environment. HOT 3
- Next.js doesn't resolve docker network defined hostnames HOT 1
- `npm start`/`next start` fails HOT 1
- Cookies, logout/auth issue after 14.2 HOT 1
- Broken loading.tsx after upgrade to v15
- Parallel Routes loading error with app dir (reproduced) HOT 2
- create-next-app Error while resolving undefined@undefined HOT 1
- npx create-next-app Error while resolving undefined@undefined HOT 1
- in vercel : /_next/image cdn error with error code 502 and warning code 400 recently HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.