28 lines
950 B
JavaScript
28 lines
950 B
JavaScript
export const url = "https://libreinternet.club/";
|
|
|
|
// Return username:password encoded in base64
|
|
export function get_login_creds() {
|
|
const username = editorusername.value;
|
|
const password = editorpassword.value;
|
|
return btoa(`${username}:${password}`);
|
|
}
|
|
|
|
async function send_request() {
|
|
const response_options = {
|
|
method: editormethod.value,
|
|
headers: {
|
|
"Authorization": `Basic ${get_login_creds()}`,
|
|
},
|
|
};
|
|
// Browser will fail the request if body is added to GET or HEAD
|
|
if (response_options.method != "GET") {
|
|
response_options.body = editorbody.value;
|
|
}
|
|
// NGINX is nonstandard in not having this as the default
|
|
if (response_options.method == "PROPFIND") {
|
|
response_options.headers["Depth"] = "1";
|
|
}
|
|
const response = await fetch(new Request("https://libreinternet.club/" + editorurl.value, response_options));
|
|
editorresponse.value = await response.text();
|
|
}
|
|
globalThis.send_request = send_request;
|