Send OPTIONS request to the WebSockets interface once per Timeout interval. This allows some deployment environment to correctly detect the status of the application

This commit is contained in:
NI
2021-04-29 14:02:52 +08:00
parent f982873b4a
commit b87d5437e5
4 changed files with 42 additions and 11 deletions

View File

@@ -15,7 +15,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
export function get(url, headers) {
function send(method, url, headers) {
return new Promise((res, rej) => {
let authReq = new XMLHttpRequest();
@@ -35,7 +35,7 @@ export function get(url, headers) {
rej(e);
});
authReq.open("GET", url, true);
authReq.open(method, url, true);
for (let h in headers) {
authReq.setRequestHeader(h, headers[h]);
@@ -44,3 +44,11 @@ export function get(url, headers) {
authReq.send();
});
}
export function get(url, headers) {
return send("GET", url, headers);
}
export function options(url, headers) {
return send("OPTIONS", url, headers);
}