1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-22 15:20:09 +01:00

CORS SUCCESS!!!

This commit is contained in:
Donald Zou 2024-08-10 19:23:50 -04:00
parent 54142b73fb
commit a650e628e5

View File

@ -15,11 +15,11 @@ export default {
}, },
methods: { methods: {
handshake(){ handshake(){
if (this.server.host && this.server.apiKey){
this.startTime = undefined; this.startTime = undefined;
this.endTime = undefined; this.endTime = undefined;
this.startTime = dayjs() this.startTime = dayjs()
fetch(`//${this.server.host}/api/handshake`, { fetch(`${this.server.host}/api/handshake`, {
headers: { headers: {
"content-type": "application/json", "content-type": "application/json",
"wg-dashboard-apikey": this.server.apiKey "wg-dashboard-apikey": this.server.apiKey
@ -30,11 +30,13 @@ export default {
this.active = true; this.active = true;
this.endTime = dayjs() this.endTime = dayjs()
}).catch((res) => { }).catch((res) => {
console.log(res) this.startTime = undefined;
this.endTime = undefined;
}) })
} }
},
}
},
mounted() { mounted() {
this.handshake() this.handshake()
}, },
@ -57,18 +59,21 @@ export default {
<div class="d-flex gap-3 align-items-center flex-grow-1"> <div class="d-flex gap-3 align-items-center flex-grow-1">
<i class="bi bi-server"></i> <i class="bi bi-server"></i>
<input class="form-control form-control-sm" <input class="form-control form-control-sm"
@blur="this.handshake()"
v-model="this.server.host" v-model="this.server.host"
type="url"> type="url">
</div> </div>
<div class="d-flex gap-3 align-items-center flex-grow-1"> <div class="d-flex gap-3 align-items-center flex-grow-1">
<i class="bi bi-key-fill"></i> <i class="bi bi-key-fill"></i>
<input class="form-control form-control-sm" <input class="form-control form-control-sm"
@blur="this.handshake()"
v-model="this.server.apiKey" v-model="this.server.apiKey"
type="text"> type="text">
</div> </div>
<div class="d-flex gap-2"> <div class="d-flex gap-2">
<button <button
@click="this.$emit('delete')" @click="this.$emit('delete')"
class="ms-auto btn btn-sm bg-danger-subtle text-danger-emphasis border-1 border-danger-subtle"> class="ms-auto btn btn-sm bg-danger-subtle text-danger-emphasis border-1 border-danger-subtle">
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
</button> </button>