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

fix: og-image 500 error in production #370

Open
pjmanning opened this issue Dec 31, 2024 · 6 comments
Open

fix: og-image 500 error in production #370

pjmanning opened this issue Dec 31, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@pjmanning
Copy link

🐛 The bug

I'm getting a 500 error with both defineOgImageScreenshot() and defineOgImageComponent()

Both show in the Nuxt DevTools ok but the image gets a 500 when deployed.

Deploying to Cloudflare via NuxtHub with @nuxtjs/seo: "2.0.2"

Tried installing "@resvg/resvg-js-linux-x64-gnu": "^2.6.2", #361 but that did not solve the issue

🛠️ To reproduce

https://stackblitz.com/edit/nuxt-starter-62jdmcub?file=package.json

🌈 Expected behavior

  • defineOgImageScreenshot() generated image shows in production
  • defineOgImageComponent() card shows in production
  • /og-image/image/og.png returns 200 image

ℹ️ Additional context

I was getting a node error in stackblitz and wasn't able to run it but the package.json, nuxt.config.ts, and file structure is correct

@pjmanning pjmanning added the bug Something isn't working label Dec 31, 2024
@harlan-zw
Copy link
Owner

Hi, I've tried to replicate this without any success. Can you provide the stacktrace for the 500 error you're getting?

@pjmanning
Copy link
Author

pjmanning commented Jan 1, 2025

Hey Harlan happy new year - and thanks for checking into this 🙏

Here is the live URL...
https://wellnesswavesapp.com/

This is the url where the image lives and what error is thrown...
https://wellnesswavesapp.com/__og-image__/image/og.png
[Error] [nuxt] error caught during app initialization
Error: Page not found: /og-image/image/og.png
Ra — Clf9TLW6.js:21:3861
Ma — Clf9TLW6.js:21:4334
(anonymous function) — Clf9TLW6.js:25:30289
runWithContext — Clf9TLW6.js:15:14766
run — Clf9TLW6.js:10:684
(anonymous function) — Clf9TLW6.js:25:30279
(anonymous function) — Clf9TLW6.js:25:30388
runWithContext — Clf9TLW6.js:15:14766
forEach
X — Clf9TLW6.js:25:20933
(anonymous function) — Clf9TLW6.js:25:19828
(anonymous function) (Clf9TLW6.js:19:27676)

If I go to http://localhost:3000/__og-image__/image/og.png while dev is running the image shows correctly. So I assume this is happening during the build.

In Cloudflare Workers I'm not seeing an uploaded image. Below is the assets uploaded...

Assets uploaded

62 Files uploaded
File name
apple-icon.png
favicon.ico
icon.png
_fonts
2-c39J9j0IaUMQZwAJyJaOX1UUnf3GLnYjA5sTNd-Y1tPUkhysb.woff
2-c39J9j0IaUMQZwAJyJaOX1UUnf3GLnYjALsTNd-8hysQyR5q6.woff
2-c39J9j0IaUMQZwAJyJaOX1UUnf3GLnYjCLtjNd-Gi90qbHzl3.woff
2-c39J9j0IaUMQZwAJyJaOX1UUnf3GLnYjDVtjNd-vV3ZJz3vp8.woff
2-c39J9j0IaUMQZwAJyJaOX1UUnf3GLnYjDstjNd-IDI0Tv17uM.woff
2-ci9J9j0IaUMQZwAJyJQubdoLNAb2XKYw-cYfWtAYeu0.woff2
2-ci9J9j0IaUMQZwAJyJQufdoLNAb2XKYw-AmmejKZsGL.woff2
2-ci9J9j0IaUMQZwAJyJQundoLNAb2U-Wh4pzOPNDs.woff2
2-ci9J9j0IaUMQZwAJyJQvvdoLNAb2XKYw-LDmBnom44K.woff2
6xK-dSZaM9iE8KbpRA_LJ3z8mH9BOJvgkBgv18I-F6n5JDJ0BN.woff
6xK-dSZaM9iE8KbpRA_LJ3z8mH9BOJvgkCEv18I-yh47Y5kS4J.woff
6xK-dSZaM9iE8KbpRA_LJ3z8mH9BOJvgkKEo18I-6OMfC9OdUK.woff
6xK-dSZaM9iE8KbpRA_LJ3z8mH9BOJvgkM0o18I-tWKQkXuPuR.woff
6xK-dSZaM9iE8KbpRA_LJ3z8mH9BOJvgkP8o18I-fukpPCNZCA.woff
6xKtdSZaM9iE8KbpRA_hJFQNYuDyP7bh-90i5XxLpNq.woff2
6xKtdSZaM9iE8KbpRA_hJVQNYuDyP7bh-U0BVMJ0M3d.woff2
6xKtdSZaM9iE8KbpRA_hK1QNYuDyPw-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j.js
entry.CA-QUGnb.css
index.Zui38rS6.css
z5ZNZeFR.js
builds

harlan-zw added a commit to harlan-zw/nuxt-og-image-playground that referenced this issue Jan 2, 2025
@harlan-zw
Copy link
Owner

I've tried to replicate this on my test Cloudflare workers instance and it seems to be working fine.

(https://playground.harlanzw.workers.dev/__og-image__/image/satori/wave/og.png)

Debugging this is a bit difficult so what I'd recommend is to prerender your home page (if possible) which will automatically have this home page og image pre-rendered as well. The zero runtime mode was made for Cloudflare workers as they have some quirks and limited size for the worker.

I'm in the process of some heavy internal improvements that should improve the stability and debugging of Cloudflare workers but likely ~1 week away from being released.

@pjmanning
Copy link
Author

pjmanning commented Jan 2, 2025

Thanks again 🙏

So I deployed a million times with different settings (thanks Nuxthub for the easy auto deploys 😆).

When I set the zero runtime config and the pre-render routes I got stuck in an infinite loop of redirects to the main domain (https://wellnesswavesapp.com). I also noticed the preview domains did not work - they redirected to the main domain.

Once I removed the redirectToCanonicalSiteUrl line it worked (both SSR and zero runtime mode).
seo: {
redirectToCanonicalSiteUrl: true,
}

Could this be due the DNS settings? I only have a CNAME record pointing to the root domain
CleanShot 2025-01-02 at 13 07 59@2x

Update:

I added another CNAME record with www and tried with the redirectToCanonicalSiteUrl set to true. This produced the same redirect loop.

I then removed the redirectToCanonicalSiteUrl setting and used the Cloudflare redirect rules template Redirect from WWW to Root https://developers.cloudflare.com/rules/url-forwarding/. This is working so I will use this for the time being.

@shidaizaiweixiao
Copy link

so ,must i delete this:seo: {
redirectToCanonicalSiteUrl: true,
}, my project's ogimage dont work in production too when i use defineogimagecomponent

@pjmanning
Copy link
Author

Not sure of your exact instance @shidaizaiweixiao but if you previously had that setting set to true, try to remove it and redeploy to see if your issue was the same as mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants