feat: add CORS support for device status endpoint

This commit is contained in:
Adam Shiervani 2025-10-14 16:17:43 +02:00
parent 53556cb64c
commit 895cd5cc39
1 changed files with 12 additions and 0 deletions

12
web.go
View File

@ -725,6 +725,18 @@ func handleDeletePassword(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{
IsSetup: config.LocalAuthMode != "",
}