next/og + Image Transformations - Unsupported image type: unknown

export const runtime = 'edge'
import { ImageResponse } from 'next/og'
import { Inter } from 'next/font/google'

// Image metadata
export const alt = 'Open Graph Image'
export const size = {
width: 1200,
height: 630,
}


export const contentType = 'image/png'

const InterRegular = Inter({
subsets: ['latin'],
variable: '--font-sans',
})

// Image generation
export default async function Image({ params }: { params: { id: number } }) {
try {
// some code..

return new ImageResponse(
(
...
<img
src={`https://<MYDOMAIN>/cdn-cgi/image/format=jpeg/${originalWebpImageUrl}`}
tw="w-[48%] border border-gray-500 rounded-md"
alt="Imagem destaque"
/>
...
)
}
export const runtime = 'edge'
import { ImageResponse } from 'next/og'
import { Inter } from 'next/font/google'

// Image metadata
export const alt = 'Open Graph Image'
export const size = {
width: 1200,
height: 630,
}


export const contentType = 'image/png'

const InterRegular = Inter({
subsets: ['latin'],
variable: '--font-sans',
})

// Image generation
export default async function Image({ params }: { params: { id: number } }) {
try {
// some code..

return new ImageResponse(
(
...
<img
src={`https://<MYDOMAIN>/cdn-cgi/image/format=jpeg/${originalWebpImageUrl}`}
tw="w-[48%] border border-gray-500 rounded-md"
alt="Imagem destaque"
/>
...
)
}
Above code works fine in local development, but in production it fails with the message
GET https://<domain>/opengraph-image?f9b52bffe5901d64 - Exception Thrown @ 7/22/2024, 4:43:04 PM
(error) error code: 1016
(error) error code: 1016
(error) error code: 1016
(error) error code: 1016
(error) Can't load image https://<domain>/cdn-cgi/image/format=jpeg/https://images.<domain>/my-image.webp: Unsupported image type: unknown
✘ [ERROR] Error: Image size cannot be determined. Please provide the width and height of the image.
GET https://<domain>/opengraph-image?f9b52bffe5901d64 - Exception Thrown @ 7/22/2024, 4:43:04 PM
(error) error code: 1016
(error) error code: 1016
(error) error code: 1016
(error) error code: 1016
(error) Can't load image https://<domain>/cdn-cgi/image/format=jpeg/https://images.<domain>/my-image.webp: Unsupported image type: unknown
✘ [ERROR] Error: Image size cannot be determined. Please provide the width and height of the image.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server