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)
- Please stop auto closing bugs like #50388! Don't put all the burden on reporters HOT 1
- Fast Refresh Failing to Work on New Project HOT 3
- NextJS 14 HMR Tailwind CSS reloading not working HOT 3
- app router - dynamic twitter card image generator file does not return anything if returned div has style: justifyContent: "end". HOT 4
- Docs: Misleading and potentially vulnerable example code of getting client's IP address HOT 4
- Error name is always overridden with "Error" HOT 1
- Problem with postcss transformation when importing css with layer HOT 1
- ReactRemoveProperties dosen't work as it was
- Turbopack dev server and HMR consuming too much memory and freezing at code changes.
- TypeError: Failed to parse URL from /api/images HOT 7
- Vercel + pages router + basePath + middleware - Full roundtrip when client navigating to index page HOT 2
- Refractor languages missing when Turbopack is enabled
- "trailingSlash" causing CORS errors HOT 1
- Version 15 breaks select form element
- Docs: Versioned Documentation HOT 3
- Docs: inaccuracy in React Foundations (Chapter 4) HOT 2
- Sitemap is being generated incorrectly and an error in development also appears when I try to access /sitemap.xml HOT 5
- Cannot use Sharp in v15.0.0-canary.1 HOT 4
- NextJS 14 returns fetch failed with UND_ERR_CONNECT_TIMEOUT error on serverless function HOT 20
- enable swcMinify compression exception { toString, fromString } => {fromString} 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.