nuxt-modules / og-image

Generate OG Images with Vue templates in Nuxt.
https://nuxtseo.com/og-image
415 stars 27 forks source link

Fetch failed - Error 500 #47

Closed luminous8 closed 1 year ago

luminous8 commented 1 year ago

Describe the bug

When loading the /__og_image__/og.png url on my production server i got an 500 error (Things works fine on my computer)

Capture d’écran 2023-05-03 à 11 33 20

[nuxt] [request error] [unhandled] [500] fetch failed (https://mydomain.com/api/og-image-options?path=/item/item-slug) at $fetchRaw2 (./.output/server/node_modules/ofetch/dist/shared/ofetch.502a4799.mjs:180:24) at ./node_modules/nuxt-og-image/dist/runtime/nitro/middleware/og.png.mjs:16:19 at Object.handler (./.output/server/node_modules/h3/dist/index.mjs:1247:19) at Server.toNodeHandle (./.output/server/node_modules/h3/dist/index.mjs:1322:7) [Vue Router warn]: No match found for location with path "/item/item-slug/__og_image__/og.png" [Vue Router warn]: No match found for location with path "/item/item-slug/__og_image__/og.png" [Vue Router warn]: No match found for location with path "/item/item-slug/__og_image__/og.png" [Vue Router warn]: No match found for location with path "/item/item-slug/__og_image__/og.png" [nuxt] [request error] [unhandled] [500] fetch failed (https://mydomain.com/api/og-image-options?path=/item/item-slug) at $fetchRaw2 (./.output/server/node_modules/ofetch/dist/shared/ofetch.502a4799.mjs:180:24) at ./node_modules/nuxt-og-image/dist/runtime/nitro/middleware/og.png.mjs:16:19 at Object.handler (./.output/server/node_modules/h3/dist/index.mjs:1247:19) at Server.toNodeHandle (./.output/server/node_modules/h3/dist/index.mjs:1322:7) [Vue Router warn]: No match found for location with path "/item/item-slug/__og_image__/og.png" [Vue Router warn]: No match found for location with path "/item/item-slug/__og_image__/og.png" [Vue Router warn]: No match found for location with path "/item/item-slug/__og_image__/og.png" [Vue Router warn]: No match found for location with path "/item/item-slug/__og_image__/og.png"

Thanks for your help!

Reproduction

/

System / Nuxt Info

System:
    OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (6) x64 AMD EPYC 7542 32-Core Processor
    Memory: 8.55 GB / 15.63 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 19.8.1 - ~/.nvm/versions/node/v19.8.1/bin/node
    npm: 9.6.2 - ~/.nvm/versions/node/v19.8.1/bin/npm
harlan-zw commented 1 year ago

Hi @luminous8, could you share what version you're using and anything else that would be useful for reproducing the error.

luminous8 commented 1 year ago

Yes, sorry (I knew i was forgetting something)

I was using 1.5.7 and I've now migrated to the ^2.0.0-beta.30 (hopping it would fix the bug)

My code is fairly simple, I'm using defineOgImageStatic({ component: 'MyOgImage', item: item, });

and my component looks like this

<script setup lang="ts">
const props = defineProps({
  job: Object,
});
</script>

<template>
  <div
    class="relative flex flex-col items-center justify-center w-full h-full p-12 bg-gray-200"
  >
    <div
      class="flex flex-col items-center justify-center w-full bg-white shadow-md rounded-xl p-14 h-max"
    >
    <div
      class="flex flex-col justify-between w-full pt-8 md:flex-row md:items-center"
    >
      <div class="flex">
        redacted text
      </div>
      <div class="flex text-right text-[24px] leading-3 mt-2 text-gray-500">
        redacted text
      </div>
    </div>
  </div>
</template>
harlan-zw commented 1 year ago

You can try to access the URL it's trying to fetch directly and see what 500 error is thrown

http://localhost:3000/api/og-image-options?path=/item/item-slug

luminous8 commented 1 year ago

I'm getting an ERR_CONNECTION_TIMED_OUT in my browser (i've done the same in local and it works perfectly)

harlan-zw commented 1 year ago

Which nitro preset are you using and are you using nuxt build or nuxt generate?

luminous8 commented 1 year ago

I'm using Nuxt build

On Wed, May 3, 2023 at 12:16 PM Harlan Wilton @.***> wrote:

Which nitro preset are you using and are you using nuxt build or nuxt generate?

— Reply to this email directly, view it on GitHub https://github.com/harlan-zw/nuxt-og-image/issues/47#issuecomment-1532775379, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIMBXLTCQFYE2SMODWTBLLXEIV6FANCNFSM6AAAAAAXUE2IOE . You are receiving this because you were mentioned.Message ID: @.***>

jfern01 commented 1 year ago

I'm having the exact same issue. Also using nuxt build.

luminous8 commented 1 year ago

update on my side: it's really weird, it started working after a couple of hours - i haven't changed anything

harlan-zw commented 1 year ago

Hmm very strange! Feel free to re-open if it pops back up :)