-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReferenceError: __DEV__ is not defined using @apollo/client in Next.js _middleware after upgrading to Node@16 #9756
Comments
@SystemDisrupt Thanks for reporting this, There are certainly a lot of things at play here. I'm curious if you have opened an issue with Next.js on this as well, also by downgrading to React 17, did it work as expected? If you do have an issue open with Next.js feel free to link to this issue. |
👋 |
I have the same error in nuxt3 Stack: Nuxi 3.0.0-rc.11 Listening http://[::]:3000 |
Reporting the same error in Sveltekit using
|
// nuxt.config.ts or vite or webpack const isDev = process.env.NODE_ENV === "development";
define: {
// fixed apollo client err
__DEV__: isDev.toString(),
}
,,, |
I am also running into this problem on a production build of nuxt on 3.0.0-rc.13 / @apollo/client:3.7.1
Unfortunately this did not help. EDIT: Have to revise my post. Defining the variable works - i just nested it wrong. Had it on the top level, while it obviously needs to be added to the vite {} node. |
Experiencing the same issue Using it under an api route that uses next/og
Snippet const retrieve = async (id: string | null) => {
if (!id) {
return undefined
}
try {
const { data } = await client.query<{ results: any[] }>({
query: TEST_QUERY,
variables: {
id,
},
})
return data
} catch (e) {
return undefined
}
}
export default async function og(req: NextRequest) {
try {
const { searchParams } = new URL(req.url)
const id = searchParams.get("id")
const data = await retrieve(id)
if (data === undefined) {
return new Response(`Failed to generate the image`, {
status: 500,
})
}
return new ImageResponse(
(
<div
style={{
height: "100%",
width: "100%",
display: "flex",
flexDirection: "column",
backgroundImage: `url("${process.env.NEXT_PUBLIC_APP_URL}/og.png")`,
backgroundSize: "1200px 630px",
backgroundRepeat: "no-repeat",
}}
>
/// CONTENT
),
{
width: 1200,
height: 600,
},
)
} catch (e) {
return new Response(`Failed to generate the image`, {
status: 500,
})
}
}
|
Hi, @SystemDisrupt 👋 We have an alpha release with a change that should improve things here, you can install it with |
Hi @SystemDisrupt 👋🏻 just wanted to follow up here - we are closing this issue as completed. Please do feel free to open a new issue if you continue to see this happening after trying |
Alpha is no good for production servers though, the change works for me but it would be better if it wasnt "alpha!" |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Intended outcome:
Call auth query with apollo client in Next.js _middleware via vercel Edge Function using Node@16
Actual outcome:
When deployed to vercel I get the following error:
I tried updating to the latest version of React, Next.js, GraphQL and Apollo Client, but got the same error. I found a few issues around React 18, so downgraded back to 17.
How to reproduce the issue:
Versions
The text was updated successfully, but these errors were encountered: