mirror of https://github.com/jetkvm/kvm.git
feat: add CORS support for device status endpoint
This commit is contained in:
parent
53556cb64c
commit
895cd5cc39
12
web.go
12
web.go
|
|
@ -725,6 +725,18 @@ func handleDeletePassword(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleDeviceStatus(c *gin.Context) {
|
func handleDeviceStatus(c *gin.Context) {
|
||||||
|
// Add CORS headers to allow cross-origin requests
|
||||||
|
// This is safe because device/status is a public endpoint
|
||||||
|
c.Header("Access-Control-Allow-Origin", "*")
|
||||||
|
c.Header("Access-Control-Allow-Methods", "GET, OPTIONS")
|
||||||
|
c.Header("Access-Control-Allow-Headers", "Content-Type")
|
||||||
|
|
||||||
|
// Handle preflight requests
|
||||||
|
if c.Request.Method == "OPTIONS" {
|
||||||
|
c.AbortWithStatus(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
response := DeviceStatus{
|
response := DeviceStatus{
|
||||||
IsSetup: config.LocalAuthMode != "",
|
IsSetup: config.LocalAuthMode != "",
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue