"Show Full Post" button doesn't work in subfolder installations

It does :slight_smile:

Are you able to access the instance this is running on? If so, could you run the following and tell me the result:

./launcher enter app
rails c
TopicEmbed.find_by(topic_id: 157441).as_json
discourse(prod)> TopicEmbed.find_by(topic_id: 157441).as_json
Serializing ActiveRecord models (TopicEmbed) without specifying fields is not allowed. Use a Serializer, or pass the :only option to #serializable_hash. More info: ``https://meta.discourse.org/t/-/314495
=>
{“id”=>56685,
“topic_id”=>157441,
“post_id”=>483289,
“embed_url”=>
“``https://tecnoblog.net/noticias/paramount-oferece-us-108-bilhoes-em-dinheiro-para-tomar-warner-da-netflix”``,
“content_sha1”=>nil,
“created_at”=>“2025-12-08T17:54:07.585Z”,
“updated_at”=>“2025-12-09T18:04:33.539Z”,
“deleted_at”=>nil,
“deleted_by_id”=>nil,
“embed_content_cache”=>“”}
discourse(prod)>

Did you edit the output before you shared it? Just looking at the embed_url value it’s

“``https://tecnoblog.net/noticias/paramount-oferece-us-108-bilhoes-em-dinheiro-para-tomar-warner-da-netflix”``

Could you just run the same command again, but this time:

./launcher enter app
rails c
TopicEmbed.find_by(topic_id: 157441).embed_url

If what you shared is indeed the value of embed_url in your db, then that is the issue, and I’ll make a small PR to discourse/discourse to handle edge cases like this where the embed_url has ended up in a malformed state.

https://github.com/discourse/discourse/pull/36753

Nope! Just copied and pasted it here.

About these backticks at the beginning and end of the url, I think it was just an error trying to format the text here in the topic, using the code button.

discourse(prod)> TopicEmbed.find_by(topic_id: 157441).embed_url
=> “https://tecnoblog.net/noticias/paramount-oferece-us-108-bilhoes-em-dinheiro-para-tomar-warner-da-netflix”
discourse(prod)>

Here you can see a topic that was created using Embed JS:

https://tecnoblog.net/comunidade/t/microsoft-edge-ganha-copilot-mode-que-promete-realizar-tarefas-usando-ia-tecnoblog/157661

The “Show Full Post” doesn’t work in this topic either.

1 Like

So the entire issue here is because the above PR started removing trailing slashes from TopicEmbed in January this year? I feel conflicted about this change. I’d prefer we respect what the admin sends us to be honest.

I think this is the root of our issues.

Can you please run the following @Thiago_Mobilon

url = "https://tecnoblog.net/noticias/governo-renova-app-da-cnh-para-baratear-obtencao-do-documento"

fd = FinalDestination.new(url, validate_uri: true, max_redirects: 5, follow_canonical: true)

uri = fd.resolve

puts uri

html = FinalDestination::HTTP.get(uri)

puts html.truncate(200)

The fd.resolve should be able to add the trailing slash on the puts uri line. I’m afraid it is failing.

1 Like
discourse(prod)> url = "https://tecnoblog.net/noticias/governo-renova-app-da-cnh-para-baratear-obtencao-do-documento"
discourse(prod)> 
discourse(prod)> fd = FinalDestination.new(url, validate_uri: true, max_redirects: 5, follow_canonical: true)
discourse(prod)> 
discourse(prod)> uri = fd.resolve
discourse(prod)> 
discourse(prod)> puts uri
discourse(prod)> 
discourse(prod)> html = FinalDestination::HTTP.get(uri)
discourse(prod)> 
discourse(prod)> puts html.truncate(200)
https://tecnoblog.net/noticias/governo-renova-app-da-cnh-para-baratear-obtencao-do-documento

=> nil
1 Like

It is not following redirects indeed. Is the forum running in the same server / IP space as the blog? It may be triggering our SSRF protection.

If that is the case you need to allow it via setting allowed_internal_hosts

2 Likes

Note that

The reason we made that change is because there was an inconsistency between how WP Discourse embeds and javascript embeds worked. Javascript embeds have always normalised the url. WP Discourse embeds came in through a different route and weren’t normalising the url (until we made the change). That led to some other inconsistencies.

2 Likes

You mean like this? (It was like this already)

No, it’s in a dedicated VPS. The blog’s machine is proxying the traffic (nginx) of the subdirectory to the discourse vps.

One other issue is that, when i run a curl to the API, searching for the topic ID of an embed URL, i can’t find it because of the trailing slash. Discourse returns a 404 page.

But if i remove the trailing slash, it returns the value:

mobilon@Thiagos-MacBook-Pro ~ % curl 'https://tecnoblog.net/comunidade/embed/info?embed_url=https://tecnoblog.net/noticias/anatel-e-receita-apreendem-quase-meio-milhao-de-produtos-em-santa-catarina/' -H 'API-KEY: <API KEY>' -H 'API-USERNAME: <USERNAME>'

<!DOCTYPE html>

<html lang="pt-BR">

<head>

  <meta charset="utf-8">

  <title>Página não encontrada - Tecnoblog Comunidade</title>
mobilon@Thiagos-MacBook-Pro ~ % curl 'https://tecnoblog.net/comunidade/embed/info?embed_url=https://tecnoblog.net/noticias/anatel-e-receita-apreendem-quase-meio-milhao-de-produtos-em-santa-catarina' -H 'API-KEY: <API KEY>' -H 'API-USERNAME: <USERNAME>' 

{"topic_id":157645,"post_id":484103,"topic_slug":"anatel-e-receita-apreendem-quase-meio-milhao-de-produtos-em-santa-catarina-tecnoblog","comment_count":15}%     

To make it work, i would need to make a str replace in wordpress, to remove the trailing slash of the permalink, before checking. But this makes no sense, the canonical URL has the trailing slash…

In practice, Discourse is normalizing the permalink to a URL that doesn’t exist… the normalized version should be the one with a trailing slash.

1 Like

Thanks to @Thiago_Mobilon I’ve found the issue and have a proposed fix

2 Likes

@Thiago_Mobilon the fix is in, can you please update?

1 Like

It works, tks Falco!

But i’m still concerned about the URLs without the trailing slash, for the reasons mentioned in my previous post. Should i open a new topic about this @angus?

Thanks, that’s great to hear.

Sure! It won’t affect the “Full Post” feature as we can now follow redirects in sites in the same domain as the forum, but you can follow up in a new topic for other concerns.

3 Likes