inertia icon indicating copy to clipboard operation
inertia copied to clipboard

Cannot move @inertiaHead in blade (to support Facebook og:image)

Open dmatis2 opened this issue 3 years ago • 5 comments

Versions:

  • @inertiajs/inertia version: ^0.11.0
  • @inertiajs/inertia-react version: ^0.8.0

Describe the problem:

I want to be able to show image in Facebook Open Graph. When I test my website using Facebook Sharing Debugger it shows me The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags.. On StackOverflow was the reason that Facebook checks og:image in only first 50kB... When I moved @inertiaHead as the first element in <head> in resources/views/app.blade.php, it was not changed.

Steps to reproduce:

  1. Open resources/views/app.blade.php
  2. Move @inertiaHead to the top of the <head> tag
  3. Clear compiled views via php artisan view:clear
  4. Restart NGINX sudo systemctl restart nginx
  5. Try website in FB Sharing Debugger

dmatis2 avatar Jul 16 '22 05:07 dmatis2

Sounds more like you don't have SSR setup or the SSR server isn't running. This requires SSR, because open-graph tags are read by reading the HTML response they receive, no JavaScript is executed at all. View the source of your page to see if it contains the correct meta tags (not through inspect element, because that shows the HTML altered by JavaScript)

RobertBoes avatar Jul 16 '22 05:07 RobertBoes

image Ahh it's not there... Can you help me on how to setup SSR, please?

dmatis2 avatar Jul 16 '22 05:07 dmatis2

@RobertBoes I go through the guide, but now I need to deploy it on the server, where NGINX serves. Sadly, it is not mentioned anywhere in the docs how to deploy it since it needs Node.js service running on port 13714 by default. Is it possible to see somewhere example configuration for NGINX to properly serve it via both HTTP and HTTPS? Thank you.

dmatis2 avatar Jul 16 '22 06:07 dmatis2

Errors I'm getting currently are:

ReferenceError: document is not defined
    at insertStyleElement (.../public/js/ssr.js:2603:15)

and

TypeError: Cannot read property 'usePage' of undefined

dmatis2 avatar Jul 17 '22 08:07 dmatis2

Is it possible to see somewhere example configuration for NGINX to properly serve it via both HTTP and HTTPS?

Why would you need to serve the NodeJS process via HTTPS?

The process is an internal resource that your server contacts to pre-render the correct HTML. You don't even need NGINX to handle anything at all (it's not public facing, so you don't need to reverse proxy any requests).

Just install PM2, start the SSR process and then save the PM2 config.

craigrileyuk avatar Aug 12 '22 22:08 craigrileyuk

Hey! Thanks so much for your interest in Inertia.js and for sharing this issue/suggestion.

In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward.

Of course there's a chance that this issue is still relevant, and if that's the case feel free to simply submit a new issue. The only thing I ask is that you please include a super minimal reproduction of the issue as a Git repo. This makes it much easier for us to reproduce things on our end and ultimately fix it.

Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️

reinink avatar Jul 28 '23 01:07 reinink