try
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"compress/flate"
|
|
||||||
"encoding/base64"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
@@ -342,18 +339,9 @@ func buildDiagramsNetURL(r *http.Request, id string, xml string) string {
|
|||||||
scheme = "https"
|
scheme = "https"
|
||||||
}
|
}
|
||||||
base := fmt.Sprintf("%s://%s/diagram?id=%s", scheme, r.Host, url.QueryEscape(id))
|
base := fmt.Sprintf("%s://%s/diagram?id=%s", scheme, r.Host, url.QueryEscape(id))
|
||||||
// For self-hosted instances that insist on proxying, avoid the remote fetch entirely by providing a compressed data
|
encoded := url.QueryEscape(base)
|
||||||
// URI in the fragment. Fragment data is not sent over the network, so this stays client-side and avoids proxy 404s.
|
// Ask draw.io not to proxy (`proxy=0`) so it fetches directly (CORS headers are already set on /diagram).
|
||||||
target := base
|
return fmt.Sprintf("%s/?splash=0&ui=min&libs=aws4&proxy=0&url=%s", drawioBaseURL, encoded)
|
||||||
if xml != "" {
|
|
||||||
var buf bytes.Buffer
|
|
||||||
w, _ := flate.NewWriter(&buf, flate.BestCompression)
|
|
||||||
_, _ = w.Write([]byte(xml))
|
|
||||||
_ = w.Close()
|
|
||||||
compressed := base64.StdEncoding.EncodeToString(buf.Bytes())
|
|
||||||
target = "data:application/octet-stream;base64," + compressed
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s/?splash=0&ui=min&libs=aws4#U%s", drawioBaseURL, target)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func addCORS(w http.ResponseWriter) {
|
func addCORS(w http.ResponseWriter) {
|
||||||
|
|||||||
Reference in New Issue
Block a user