Update CORS handling for web image viewing and adjust host assignment in publicFileShareHandler
This commit is contained in:
@@ -105,8 +105,8 @@ class FileViewerDispatch {
|
||||
);
|
||||
} else if (mimeType.startsWith('image/')) {
|
||||
Widget child;
|
||||
if (kIsWeb) {
|
||||
// Use HTML img element for web to handle CORS
|
||||
if (kIsWeb && token == null) {
|
||||
// Use HTML img element for web public shares to handle CORS
|
||||
ui_web.platformViewRegistry.registerViewFactory(viewerId, (int viewId) {
|
||||
final imgElement = web.HTMLImageElement()
|
||||
..src = url
|
||||
@@ -124,7 +124,7 @@ class FileViewerDispatch {
|
||||
|
||||
child = HtmlElementView(viewType: viewerId);
|
||||
} else {
|
||||
// For mobile, use Image.network
|
||||
// For mobile or authenticated web, use Image.network with headers
|
||||
child = Image.network(
|
||||
url,
|
||||
headers: headers,
|
||||
|
||||
BIN
go_cloud/api
BIN
go_cloud/api
Binary file not shown.
@@ -2952,7 +2952,10 @@ func publicFileShareHandler(w http.ResponseWriter, r *http.Request, db *database
|
||||
} else if r.TLS == nil {
|
||||
scheme = "http"
|
||||
}
|
||||
host := "www.b0esche.cloud"
|
||||
host := r.Host
|
||||
if host == "" {
|
||||
host = "go.b0esche.cloud"
|
||||
}
|
||||
downloadPath := fmt.Sprintf("%s://%s/public/share/%s/download?token=%s", scheme, host, token, url.QueryEscape(viewerToken))
|
||||
viewPath := fmt.Sprintf("%s://%s/public/share/%s/view?token=%s", scheme, host, token, url.QueryEscape(viewerToken))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user