Skip to content
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

exports is not defined in Open-Graph ImageResponse(page route api) #55430

Closed
1 task done
iga00257 opened this issue Sep 15, 2023 · 6 comments
Closed
1 task done

exports is not defined in Open-Graph ImageResponse(page route api) #55430

iga00257 opened this issue Sep 15, 2023 · 6 comments
Assignees
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@iga00257
Copy link

Link to the code that reproduces this issue or a replay of the bug

https://github.com/va3y/grammy-next-edge/blob/next/pages/api/bot.ts

To Reproduce

Run the dev server and access the route
the og-image issue is the same as the repo url above

import { ImageResponse } from '@vercel/og'
import { NextRequest } from 'next/server'

export const config = {
  runtime: 'edge',
}

export default async function handler(request: NextRequest) {
  const { searchParams } = request.nextUrl
  return new ImageResponse(
    (
      <>
        <div
          style={{
            position: 'relative',
            display: 'flex',
            flexDirection: 'column',
            justifyContent: 'center',
            alignItems: 'center',
            width: '100%',
            height: '100%',
          }}
        />
      </>
    ),
    {
      width: 1200,
      height: 630,
    },
  )
}

Current vs. Expected behavior

in next-13.4.3 the image response work well, but in next 13.16

I got the error in terminal , seems like exports is not supported in

- error Error [ReferenceError]: exports is not defined
- ReferenceError: exports is not defined
    at eval (webpack-internal:///(middleware)/./node_modules/next/dist/compiled/@vercel/og/index.edge.js:3:23)
    at (middleware)/./node_modules/next/dist/compiled/@vercel/og/index.edge.js (/Users/Project/shop-frontend/build/server/pages/api/og/product.js:1845:1)
    at __webpack_require__ (/Users/Project/shop-frontend/build/server/edge-runtime-webpack.js:37:33)
    at Function.fn (/Users/Project/shop-frontend/build/server/edge-runtime-webpack.js:295:21)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

If any issue is relation with my problem please tell me thanks

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.5.0
    Binaries:
      Node: v20.5.0
      npm: 9.8
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.4.16-canary.4
      eslint-config-next: 13.4.4
      react: 18.2.6
      react-dom: 18.2.4
      typescript: 5.0.4

Which area(s) are affected? (Select all that apply)

Middleware / Edge (API routes, runtime)

Additional context

No response

@iga00257 iga00257 added the bug Issue was opened via the bug report template. label Sep 15, 2023
@iga00257 iga00257 changed the title exports is not defiedOpen-Graph Image exports is not defined in Open-Graph Image Sep 15, 2023
@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label Sep 15, 2023
@iga00257 iga00257 changed the title exports is not defined in Open-Graph Image exports is not defined in Open-Graph ImageResponse(page route api) Sep 15, 2023
@PeterKow
Copy link

Same here, even example code from doc doesn't work, also update nextjs and @vercel/og to latest

@Ushlerdop
Copy link

@iga00257 @PeterKow hey guys, hello!
Have you found a solution?

@dnzg

This comment has been minimized.

@tomtobac

This comment has been minimized.

@kdy1
Copy link
Member

kdy1 commented Jan 30, 2024

Closing as fixed on the canary.
image

@kdy1 kdy1 closed this as completed Jan 30, 2024
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

No branches or pull requests

6 participants