fix(im): make presigned URL flow diagnosable end-to-end

When IM image rendering breaks, operators previously had no log line to
correlate against the IM platform's fetch attempt. Add observability
hooks on both ends and unblock HEAD probes so common IM previews work
at all.

- log rewriteStorageURLs success/failure/no-op with the full signed URL
  (operators can copy it from logs and verify public reachability)
- log presigned handler 4xx with client_ip + UA + tenant_id + file_path
  so failures correlate against IM platform fetch logs; use the request
  context so trace IDs are preserved
- accept HEAD on /api/v1/files/presigned: IM platforms (Feishu, Slack
  etc.) probe with HEAD before GET when rendering image previews, and a
  401 there is enough to break the inline image even when the GET would
  have succeeded
- add Admin-only GET /api/v1/files/presigned-preview that returns the
  exact URL an IM channel would embed for the calling tenant, for
  self-service verification without sending a real IM message
- clarify APP_EXTERNAL_URL and MINIO_ENDPOINT public-reachability rules
  in .env.example; misconfigured endpoints are the most common cause of
  "image broken in IM" reports
This commit is contained in:
wizardchen
2026-05-27 20:50:20 +08:00
committed by lyingbug
parent f5820c13ac
commit ae4ec0cf06
5 changed files with 395 additions and 23 deletions
+4 -1
View File
@@ -29,7 +29,10 @@ var noAuthAPI = map[string][]string{
"/api/v1/auth/oidc/url": {"GET"},
"/api/v1/auth/oidc/callback": {"GET"},
"/api/v1/auth/refresh": {"POST"},
"/api/v1/files/presigned": {"GET"},
// IM platforms (Feishu, Slack, etc.) commonly issue a HEAD request
// before GET to validate Content-Type / Content-Length when rendering
// image previews — both verbs must be allowed for image links to work.
"/api/v1/files/presigned": {"GET", "HEAD"},
}
// 检查请求是否在无需认证的API列表中