openmates 0.11.0-alpha.5 → 0.11.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OS5XPQOD.js → chunk-NU4XR6MF.js} +13 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -4858,10 +4858,22 @@ function getUploadUrl(apiUrl) {
|
|
|
4858
4858
|
}
|
|
4859
4859
|
return "https://upload.openmates.org";
|
|
4860
4860
|
}
|
|
4861
|
+
function getUploadOrigin(apiUrl) {
|
|
4862
|
+
try {
|
|
4863
|
+
const url = new URL(apiUrl);
|
|
4864
|
+
if (url.hostname === "localhost") return "http://localhost:5173";
|
|
4865
|
+
if (url.hostname.startsWith("api.")) {
|
|
4866
|
+
return `${url.protocol}//app.${url.hostname.slice(4)}`;
|
|
4867
|
+
}
|
|
4868
|
+
} catch {
|
|
4869
|
+
}
|
|
4870
|
+
return "https://app.openmates.org";
|
|
4871
|
+
}
|
|
4861
4872
|
async function uploadFile(filePath, session) {
|
|
4862
4873
|
const filename = basename2(filePath);
|
|
4863
4874
|
const fileBytes = readFileSync4(filePath);
|
|
4864
4875
|
const uploadUrl = `${getUploadUrl(session.apiUrl)}/v1/upload/file`;
|
|
4876
|
+
const origin = getUploadOrigin(session.apiUrl);
|
|
4865
4877
|
const cookies = [];
|
|
4866
4878
|
if (session.cookies?.auth_refresh_token) {
|
|
4867
4879
|
cookies.push(`auth_refresh_token=${session.cookies.auth_refresh_token}`);
|
|
@@ -4877,6 +4889,7 @@ async function uploadFile(filePath, session) {
|
|
|
4877
4889
|
method: "POST",
|
|
4878
4890
|
body: formData,
|
|
4879
4891
|
headers: {
|
|
4892
|
+
Origin: origin,
|
|
4880
4893
|
...cookies.length > 0 ? { Cookie: cookies.join("; ") } : {}
|
|
4881
4894
|
},
|
|
4882
4895
|
signal: AbortSignal.timeout(10 * 60 * 1e3)
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED