diff --git a/public/js/edit.js b/public/js/edit.js index 5e40c64..60f14cf 100644 --- a/public/js/edit.js +++ b/public/js/edit.js @@ -3,7 +3,7 @@ function saveText() { const options = {method: 'POST', body: JSON.stringify({text: x}), headers: { 'Content-Type': 'application/json' }}; - fetch('http://127.0.0.1:8000/api/edit', options) + fetch(location.protocol + '/api/edit', options) .then((response) => response.text()) .then(data => { redirectOrNot(data); @@ -12,6 +12,6 @@ function saveText() { } async function redirectOrNot(res) { - let url = "http://" + location.hostname + ":" + location.port + let url = location.protocol location.href = url+res -} \ No newline at end of file +} diff --git a/public/js/login.js b/public/js/login.js index 7bb649e..cc69382 100644 --- a/public/js/login.js +++ b/public/js/login.js @@ -2,7 +2,7 @@ function formLink() { let x = document.getElementById("Token").value; const options = {method: 'POST', headers: {Token: x}}; - fetch('http://127.0.0.1:8000/login', options) + fetch(location.protocol + '/login', options) .then((response) => response.text()) .then(data => { redirectOrNot(data); @@ -12,6 +12,7 @@ function formLink() { } async function redirectOrNot(res) { - let url = "http://" + location.hostname + ":" + location.port + let url = location.protocol location.href = url+res -} \ No newline at end of file + +} diff --git a/public/js/main.js b/public/js/main.js index 1a4ef9f..5513c6d 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -1,5 +1,5 @@ !async function(){ - let data = await fetch("http://localhost:8000/api") + let data = await fetch(location.protocol + "/api") .then((response) => response.text()) .then(data => { return data;