Onebox previews are not working for my site

i have a site to which i added the required <meta> OpenGraph tags to, but is not displaying any Onebox previews. it is passing OpenGraph validation, so i doubt it is a markup issue.

(i cannot post a link to the validator, because i am a new user)

i can observe on the server end that it is indeed serving pages to the Discourse robot:

User-Agent: 'Discourse Forum Onebox v3.3.0.beta1-dev'
IP Address: 2602:fd3f:3:204:0:242:ac11:2d

but the links just do not show up:

https://swiftinit.org/docs/swift/swift/arrayslice

i considered that the problem could be because we return 505 HTTP Version Not Supported for HEAD requests, based on this thread. so i patched our server to return a perfunctory 200 OK response for the HEAD method:

> HEAD / HTTP/1.1
> Host: swiftinit.org
> User-Agent: curl/7.81.0
> Accept: */*
> 

< HTTP/1.1 200 OK
< host: swiftinit.org
< access-control-allow-origin: *
< content-length: 0
< content-type: text/html; charset=utf-8
< 

however, this is still not working.

1 Like

Hi, welcome :wave:

Can you check if your server doesn’t block the requests? From what I see, I get 400 as an error code (when I look at the Discourse fetch response)

2 Likes

i see, i have reconfigured the site to treat HEAD requests identically to GET requests.

the site has a security policy that will return 400 unless the client sends a user agent string that starts with the string "Discourse Forum Onebox" and an Accept-Language: * header. i am able to pass the filter using curl with the following settings:

$ curl -v -I --http1.1 \
    -A 'Discourse Forum Onebox v3.3.0.beta1-dev' \
    -H 'Accept-Language: *' \
    https://swiftinit.org -o /dev/null
> HEAD / HTTP/1.1
> Host: swiftinit.org
> User-Agent: Discourse Forum Onebox v3.3.0.beta1-dev
> Accept: */*
> Accept-Language: *
> 

< HTTP/1.1 200 OK
< host: swiftinit.org
< link: <https://swiftinit.org/>; rel="canonical"
< etag: "8898806577480f6f7e5241ff270a9201"
< access-control-allow-origin: *
< content-length: 18933
< content-type: text/html; charset=utf-8
< 

is there a way i can see the discourse fetch response?

From what I see, it’s a GET request, and only User-Agent header is passed. Right now, it returns a Bad Request.

I don’t think there is a direct way to see the response; I added some debug log directly into the code.

1 Like

ah that was it, it had a filter on the Accept-Language header, which the bot doesn’t send with all requests. thank you so much!

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.