OPTIONS endpoint for CORS preflight

master
Keith Irwin 2022-09-13 11:33:13 -06:00
parent 3b77fb8062
commit 89bce70a60
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
2 changed files with 3 additions and 1 deletions

View File

@ -21,6 +21,9 @@ case "${REQUEST_METHOD}" in
# Delete peer
'DELETE') "${LIB_DIR}/peer_del" "${HTTP_X_REAL_IP}" "${QUERY_STRING}";;
# Needed for CORS preflight
'OPTIONS') "${LIB_DIR}/http_res" 200;;
# Bad request
*) printf 'Invalid HTTP verb' | "${LIB_DIR}/http_res" 405;;

View File

@ -87,7 +87,6 @@ function PeerList() {
self.delPeer = async (peer) => {
if (confirm(`Are you sure you want to delete ${peer.name}?`)) {
peer.isDeleting(true)
console.log(`Deleting ${peer.pubkey}`)
const url = `${API_URL}/?t=${self.token}&pubkey=${peer.pubkey}`
try {
const res = await fetch(url, {method: 'DELETE'})