-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Please confirm the following
-
I have read and agree to AGPL-3.0 Section 15 .
The program is provided "as is" without any warranties; you bear all risks of using it. -
I have read and agree to AGPL-3.0 Section 16 .
The copyright holders and distributors are not liable for any damages resulting from the use or inability to use the program. -
I confirm my description is clear, polite, helps developers quickly locate the issue, and complies with community rules.
-
I have read the OpenList documentation.
-
I confirm there are no duplicate issues or discussions.
-
I confirm this is an
OpenListissue, not caused by other reasons (such as network, dependencies, or operation). -
I believe this issue must be handled by
OpenListand not by a third party. -
I confirm this issue is not fixed in the latest version.
-
I have not read these checkboxes and therefore I just ticked them all, Please close this issue
OpenList Version (required)
4.1.9
Storage Driver Used (required)
Local, sftp
Bug Description (required)
PDF.js failed to preview because $e_url is resolved with http protocol, resulting in Mixed content error, and the PDF in preview is blank.
Probably related to:
OpenList/server/common/base.go
Lines 13 to 31 in 0c46199
| func GetApiUrlFromRequest(r *http.Request) string { | |
| api := conf.Conf.SiteURL | |
| if strings.HasPrefix(api, "http") { | |
| return strings.TrimSuffix(api, "/") | |
| } | |
| if r != nil { | |
| protocol := "http" | |
| if r.TLS != nil || r.Header.Get("X-Forwarded-Proto") == "https" { | |
| protocol = "https" | |
| } | |
| host := r.Header.Get("X-Forwarded-Host") | |
| if host == "" { | |
| host = r.Host | |
| } | |
| api = fmt.Sprintf("%s://%s", protocol, stdpath.Join(host, api)) | |
| } | |
| api = strings.TrimSuffix(api, "/") | |
| return api | |
| } |
Especially when user is running OpenList in docker.
Setting SiteURL with correct https protocol will fix this, however, this is not mentioned in the OpenList docs (FAQ - Why can't I preview the PDF file). The docs only stated that some features may not work if this is not set, see here.
Logs (required)
Logs are not related in this issue.
Configuration File Content (required)
Configuration file is not related in this issue.
Reproduction Link (optional)
This issue can be reproduced with any PDF file, extracting the PDF.js viewer and open it in a browser have the same behavior. Replace http with https will render the PDF correctly.
