mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
API: Add OPTIONS wildcard handler to serve CORS preflight requests #5133
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
19
internal/api/options.go
Normal file
19
internal/api/options.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Options returns an empty response to handle CORS preflight requests.
|
||||
//
|
||||
// @Summary returns CORS headers with an empty response body
|
||||
// @Id Options
|
||||
// @Success 204
|
||||
// @Router /api/v1/{any} [options]
|
||||
func Options(router *gin.RouterGroup) {
|
||||
router.OPTIONS("/*any", func(c *gin.Context) {
|
||||
c.Status(http.StatusNoContent)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user