서브폴더 설치에서 「전체 게시물 보기」 버튼이 작동하지 않음

가능합니다 :slight_smile:

해당 인스턴스에 접근할 수 있나요? 그렇다면 다음 명령을 실행하고 결과를 알려주실 수 있을까요:

./launcher enter app
rails c
TopicEmbed.find_by(topic_id: 157441).as_json
discourse(prod)> TopicEmbed.find_by(topic_id: 157441).as_json
ActiveRecord 모델(TopicEmbed)을 직렬화할 때 필드를 지정하지 않는 것은 허용되지 않습니다. Serializer를 사용하거나 #serializable_hash에 :only 옵션을 전달하세요. 자세한 정보: ``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)>

공유하기 전에 출력을 편집했나요? embed_url 값만 봐도

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

이런 상태입니다.

같은 명령어를 다시 실행해 주시겠어요? 이번에는 아래처럼요:

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

공유하신 내용이 실제로 db의 embed_url 값이라면, 이것이 문제의 원인입니다. embed_url이 잘못된 형태로 저장된 것과 같은 엣지 케이스를 처리하기 위해 discourse/discourse에 작은 PR을 만들겠습니다.

아니요! 여기 그대로 복사해서 붙여넣었습니다.

URL 앞뒤의 백틱은 아마 이 토픽에서 코드 버튼을 사용하여 텍스트를 서식 설정하려다 생긴 오류일 것 같습니다.

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)>

여기서 Embed JS를 사용하여 생성된 토픽을 볼 수 있습니다:

이 토픽에서도 “전체 게시물 보기” 기능이 작동하지 않습니다.

그러면 이번 문제의 전부가 올해 1월에 위 PR이 TopicEmbed에서 뒤쪽 슬래시를 제거하기 시작했기 때문인가요? 이 변경 사항에 대해 갈등을 느끼고 있습니다. 솔직히 관리자님이 보내준 값을 그대로 존중하는 편이 더 좋겠습니다.

이것이 우리 문제의 근본 원인이라고 생각합니다.

@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)

fd.resolve는 puts uri 라인에서 뒤쪽 슬래시를 추가할 수 있어야 합니다. 실패하는 것 같아 우려됩니다.

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

실제로 리디렉트를 따르지 않고 있습니다. 포럼이 블로그와 동일한 서버/IP 공간에서 실행되고 있나요? 그렇게 되면 SSRF 보호 기능이 트리거될 수 있습니다.

그렇다면 allowed_internal_hosts 설정을 통해 허용해야 합니다.

참고로

그 변경 사항을 수행한 이유는 WP Discourse 임베드와 자바스크립트 임베드의 동작 방식 사이에 일관성이 없었기 때문입니다. 자바스크립트 임베드는 항상 URL을 정규화(normalise)해 왔지만, WP Discourse 임베드는 다른 경로를 통해 들어와 URL을 정규화하지 않았습니다(우리가 변경하기 전까지는요). 이로 인해 다른 일관성 문제들이 발생했습니다.

이렇게 말씀하시는 건가요? (이미 이렇게 되어 있었습니다)

아니요, 전용 VPS에 있습니다. 블로그 머신이 서브디렉토리의 트래픽(nginx)을 discourse VPS로 프록시하고 있습니다.

또 다른 문제는 API에 curl 요청을 보낼 때, 임베드 URL의 주제 ID를 검색하면 끝부분의 슬래시 때문에 해당 ID를 찾을 수 없다는 점입니다. Discourse가 404 페이지를 반환합니다.

하지만 끝부분의 슬래시를 제거하면 값을 반환합니다:

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}%     

이를 작동시키려면 확인 전에 워드프레스에서 영구 링크의 끝부분 슬래시를 제거하는 문자열 대체를 수행해야 합니다. 하지만 이는 말이 되지 않습니다. 정준 URL(canonical URL)에는 끝부분 슬래시가 포함되어 있거든요…

실제로 Discourse는 존재하지 않는 URL로 영구 링크를 정규화하고 있습니다… 정규화된 버전은 끝부분 슬래시가 있는 것이어야 합니다.

@Thiago_Mobilon 덕분에 문제를 찾았고, 수정안을 제안했습니다

@Thiago_Mobilon 수정이 완료되었습니다. 업데이트해 주시겠어요?

동작합니다, Falco님 감사합니다!

하지만 이전 게시물에서 언급한 이유 때문에, 끝부분에 슬래시가 없는 URL에 대해 여전히 우려가 있습니다. 이 문제에 대해 @angus님에게 새 주제를 여는 것이 좋을까요?

감사합니다. 기쁜 소식입니다.

물론입니다! 이제 포럼과 동일한 도메인 내 사이트의 리다이렉트를 따라갈 수 있으므로 ‘Full Post’ 기능에는 영향을 주지 않습니다. 하지만 다른 우려 사항에 대해서는 새 주제에서 후속 조치를 취하셔도 됩니다.