add cors header for API endpoints (closes #55)
Some checks are pending
mozhi pipeline / Build and publish artifacts (push) Waiting to run
mozhi pipeline / Push Docker image to Codeberg docker registry (push) Waiting to run

This commit is contained in:
Arya 2024-12-27 12:38:43 +05:30
parent 099885f315
commit 8d3855589f
Signed by: arya
GPG Key ID: 842D12BDA50DF120

View File

@ -95,6 +95,11 @@ func Serve(port string) {
})
api := app.Group("/api")
// Set CORS Header for all API endpoints
api.Use(func(c *fiber.Ctx) error {
c.Set("Access-Control-Allow-Origin", "*")
return c.Next()
})
api.All("/translate", pages.HandleTranslate)
api.All("/image", pages.HandleImg)
api.Get("/source_languages", pages.HandleSourceLanguages)