add localhost http post proxy support for onshape or other https -> http scenarios
This commit is contained in:
parent
ca3b515df5
commit
9bd0a4974d
7 changed files with 240 additions and 2 deletions
|
|
@ -247,7 +247,8 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
ajax = new XMLHttpRequest(),
|
||||
host = octo_host.value.toLowerCase(),
|
||||
apik = octo_apik.value,
|
||||
type = octo_type.value;
|
||||
type = octo_type.value,
|
||||
proxy = api.feature.proxy ? host : undefined;
|
||||
|
||||
if (host.indexOf("http") !== 0) {
|
||||
api.show.alert("host missing protocol (http:// or https://)");
|
||||
|
|
@ -262,6 +263,11 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
localSet('octo-apik', apik.trim());
|
||||
localSet('octo-type', type.trim());
|
||||
|
||||
if (proxy) {
|
||||
console.log('proxying request to', host);
|
||||
host = '';
|
||||
}
|
||||
|
||||
filename = $('print-filename').value + "." + fileext;
|
||||
form.append("file", getBlob(), filename);
|
||||
ajax.onreadystatechange = function() {
|
||||
|
|
@ -297,6 +303,9 @@ function exportGCodeDialog(gcode, sections, info, names) {
|
|||
} else {
|
||||
ajax.open("POST", host + "/api/files/local");
|
||||
}
|
||||
if (proxy) {
|
||||
ajax.setRequestHeader("X-Host", proxy);
|
||||
}
|
||||
if (apik) {
|
||||
ajax.setRequestHeader("X-Api-Key", apik);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue