Giter Club home page Giter Club logo

Comments (15)

gengjiawen avatar gengjiawen commented on June 2, 2024

@siddhsuresh Can you take a look, thx.

from blitz.

gengjiawen avatar gengjiawen commented on June 2, 2024

remove eval works for me. My guessing is that eval won't compatible with minifier.

from blitz.

tordans avatar tordans commented on June 2, 2024

@gengjiawen can you be a bit more specific? Thanks!

We are also having this problem...

from blitz.

gengjiawen avatar gengjiawen commented on June 2, 2024

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.

siddhsuresh avatar siddhsuresh commented on June 2, 2024

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.

gengjiawen avatar gengjiawen commented on June 2, 2024

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.

siddhsuresh avatar siddhsuresh commented on June 2, 2024

okay thanks for the info. will keep that in mind and debug

from blitz.

cfragkos avatar cfragkos commented on June 2, 2024

probably related to #4309. Please fix it fast

from blitz.

gengjiawen avatar gengjiawen commented on June 2, 2024

@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.

siddhsuresh avatar siddhsuresh commented on June 2, 2024

@gengjiawen where is getBlitzContext being imported from? if you are importing from "@blitz/auth" instead import it from "app/blitz-server"

from blitz.

gengjiawen avatar gengjiawen commented on June 2, 2024

@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.

gengjiawen avatar gengjiawen commented on June 2, 2024

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.

flybayer avatar flybayer commented on June 2, 2024

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.

cfragkos avatar cfragkos commented on June 2, 2024

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.

cfragkos avatar cfragkos commented on June 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.