This commit is contained in:
2025-03-24 01:15:32 -06:00
parent 0b85919395
commit 4547bf9f6e
2 changed files with 18 additions and 0 deletions

View File

@ -30,6 +30,14 @@ func SSE(c echo.Context) error {
c.Response().Header().Set(echo.HeaderConnection, "keep-alive")
c.Response().Header().Set(echo.HeaderCacheControl, "no-cache")
// Get origin from request
origin := c.Request().Header.Get(echo.HeaderOrigin)
// Only allow specific origins
if origin == "https://atri.dad" || origin == "http://localhost:3000" {
c.Response().Header().Set(echo.HeaderAccessControlAllowOrigin, origin)
c.Response().Header().Set(echo.HeaderAccessControlAllowCredentials, "true")
}
// Create a channel to receive messages from the lib.SSEServer
clientChan := make(chan string)