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)
- Next.js downloads from fonts.googleapis.com during build HOT 1
- Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node HOT 1
- Can't use Intercepting and Parallel routes in root level HOT 1
- Error: You cannot use both an required and optional catch-all route
- Error: You cannot use both an required and optional catch-all route
- Incorrect caching
- Docs: Missing custom Partytown configuration for `Script` with `strategy="worker"`
- Endless issues of Error: Cannot find module '....\.next\server\vendor-chunks\lib\worker.js'
- Conditional building pages with export: output is not supported
- Update eslint-config-next @typescript-eslint/typescript-estree version to support Typescript 5.5 HOT 1
- Next.js bundles libraries only used in Server Components into the Client Bundle Chunks
- [turbo] an unexpected Turbopack error occured HOT 3
- Why the response data is so big in browser when I use the server action with cookies().set or cookies().delete or etc that modify the cookie HOT 2
- NextResponse throws error when http request status code is 204 HOT 1
- BUG: incorrect url encoding in `<link rel="preload">` for prioritized images
- `next/font` interferes with header links from middleware.
- Can't use bcrypt in middleware HOT 4
- It hasn't been resolved for several months. accesstoken reissue issue
- Error and reload during HMR with MUI HOT 1
- Error and reload during HMR with MUI
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.