Comments (15)
@siddhsuresh Can you take a look, thx.
from blitz.
remove eval
works for me. My guessing is that eval won't compatible with minifier.
from blitz.
@gengjiawen can you be a bit more specific? Thanks!
We are also having this problem...
from blitz.
patch node modules like this (I am using pnpm)
diff --git a/dist/chunks/auth-plugin.cjs b/dist/chunks/auth-plugin.cjs
index beef77a9f480f095381f176b0da5a3c77c4ee25e..dff1216e3f4c6cacc2ba0e05d12254e56679e471 100644
--- a/dist/chunks/auth-plugin.cjs
+++ b/dist/chunks/auth-plugin.cjs
@@ -162,7 +162,7 @@ function getSession(req2, res2, appDir = false) {
function getBlitzContext() {
return __async$1(this, null, function* () {
try {
- const { headers, cookies } = eval("require('next/headers')");
+ const { headers, cookies } = require('next/headers');
const req = new http.IncomingMessage(new net.Socket());
req.headers = Object.fromEntries(headers());
const csrfToken = cookies().get(index.COOKIE_CSRF_TOKEN());
@@ -201,7 +201,7 @@ function useAuthenticatedBlitzContext(_0) {
const ctx = yield getBlitzContext();
const userId = ctx.session.userId;
try {
- const { redirect } = eval("require('next/navigation')");
+ const { redirect } = require('next/navigation');
if (userId) {
debug("[useAuthenticatedBlitzContext] User is authenticated");
if (redirectAuthenticatedTo) {
from blitz.
thanks for the issue @gengjiawen! I will take a look today.
Does this happen locally for you? Since I am no longer able to replicate this after the latest fix.
from blitz.
Does this happen locally for you
If you refer to the deploy issue, The deploy issue only happens on nextjs. My local yarn start works.
from blitz.
okay thanks for the info. will keep that in mind and debug
from blitz.
probably related to #4309. Please fix it fast
from blitz.
@siddhsuresh vercel also breaks this, not sure it's the same problem.
Repro is use this in app router api
async function handle(req: Request) {
const ctx = await getBlitzContext()
if (!ctx.session.userId) {
return new Response("Unauthorized", { status: 401 })
}
Error:
⨯ Error: Internal Blitz Error: globalThis.__BLITZ_SESSION_COOKIE_PREFIX is not set
at prefix (/var/task/.next/server/chunks/3637.js:93:126631)
at Object.COOKIE_CSRF_TOKEN (/var/task/.next/server/chunks/3637.js:93:126968)
at /var/task/.next/server/chunks/3637.js:93:107389
at Generator.next (<anonymous>)
at /var/task/.next/server/chunks/3637.js:93:105600
at new Promise (<anonymous>)
at __async$1 (/var/task/.next/server/chunks/3637.js:93:105378)
at getBlitzContext (/var/task/.next/server/chunks/3637.js:93:107231)
at handle (/var/task/.next/server/app/api/claude/route.js:1:1912)
at /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39754
from blitz.
@gengjiawen where is getBlitzContext
being imported from? if you are importing from "@blitz/auth" instead import it from "app/blitz-server"
from blitz.
@gengjiawen where is
getBlitzContext
being imported from? if you are importing from "@blitz/auth" instead import it from "app/blitz-server"
import from blitz-server will result in build error.
Attempted import error: 'setupBlitzServer' is not exported from '@blitzjs/next' (imported as 'setupBlitzServer').
adding a new issue: #4310
from blitz.
since this has been 3 weeks, I have created #4311 to fix this issue.
This fix all the issues I run into in productions.
from blitz.
Hey folks, we have investigated, can reproduce, but so far are unable to understand what is happening on Vercel.
Are any of you able to reach out to Vercel support and enlist their help?
from blitz.
Yes I am in contact, and got them to investigate, they were quick to blame the 3rd party dependency, but I pressed them after investigating the source code that the way you import and use debug is not wrong and it's their problem, so it seems they will look into it, I suggest you also reach out because you have more technical knowledge to explain than me
from blitz.
Got my answer today
Hi again,
Thank you for waiting. I have reviewed this issue with our team's framework-related expert and can confirm that investigating why the "debug" package is not working on Next.js 14 would require implementation-level debugging which is not in the purview of this support team.
The Blitz.js repo is the best place for this, so, that you're able to get support from framework developers and maintainers.
If there are any other platform-related Qs or issues that you may have, do let me know!
from blitz.
Related Issues (20)
- Cannot find module 'next/dist/client/resolve-href' HOT 1
- BLITZ_PUBLIC_ prefix does not expose env to client HOT 2
- BlitzRoutes: Support app router HOT 4
- Windows Compatibility Issue: process.kill("SIGABRT") not supported HOT 5
- useAuthenticatedBlitzContext fails on vercel HOT 8
- getBlitzContext unusable in api HOT 2
- getBlitzContext() can't be use in edge funcion HOT 2
- nextjs (app router) fails on vercel HOT 1
- v2.0.7 `pnpm blitz dev --turbo` error with Invalid next.config.js options HOT 2
- enhancePrisma has disappeared since v2.0.7
- No matching version found for @blitzjs/[email protected] HOT 1
- useAuthenticatedBlitzContext doesn not populate next url param on redirect (app router)
- Allow override of "target" for ES2016+ features in Custom Server HOT 1
- ensure every page has `export const metadata`
- codemod at least has a typo, and maybe other problems HOT 4
- formik added when i pick final-form
- Blitz Auth: Blitz CTX session not populated in api route called from Next.js middleware HOT 2
- When I use a client component in root layout the server returns a 500 error HOT 3
- Can not use useMutation in BlitzPage HOT 1
- enhanced security by default HOT 3
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 blitz.