Open Graph og:image uses relative URL instead of absolute, causing social preview issues #2602
-
Hi, thanks for the great work on Vike! <meta property="og:image" content="/assets/static/preview.CvqgeWl5.jpeg" /> This results in warnings from social platforms like Facebook (e.g., “URL not valid”), since Open Graph requires absolute URLs (e.g., https://example.com/assets/...). Expected behavior: <meta property="og:image" content="https://example.com/assets/static/preview.CvqgeWl5.jpeg" /> Steps to reproduce: URL not valid — relative path provided. https://developers.facebook.com/tools/debug/ Thx! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It's Vite that returns relative URLs when importing static assets, which makes sense: Vite doesn't know your domain name (nor does Vike btw).
That seems like a silly requirement? Relative URLs are ubiquitous. So it seems to be more of a Facebook quirk? Are you sure it doesn't actually work? It could just be a wrong warning. Note that (You can also re-create full URLs manually yourself, although I would go down that path unless I'm 100% sure it's really required.) |
Beta Was this translation helpful? Give feedback.
Yes, it does seem like a strange requirement, but I assume Facebook (and similar platforms) prefer absolute URLs to avoid having to resolve the domain on their side every time. I also suspect that value is cached on their end, so having a fully qualified URL makes it easier for them to handle.
To resolve it, I passed the image as an absolute URL in +config, and that solved the issue.