Browse Source

fix(install): sse check #1069, #1070

Jacky 1 month ago
parent
commit
0d3f24ca48
2 changed files with 6 additions and 6 deletions
  1. 2 0
      api/system/self_check.go
  2. 4 6
      app/src/composables/useSSE.ts

+ 2 - 0
api/system/self_check.go

@@ -9,6 +9,7 @@ import (
 
 	"time"
 
+	"github.com/0xJacky/Nginx-UI/api"
 	"github.com/0xJacky/Nginx-UI/internal/self_check"
 	"github.com/gin-gonic/gin"
 )
@@ -45,6 +46,7 @@ func CheckWebSocket(c *gin.Context) {
 }
 
 func CheckSSE(c *gin.Context) {
+	api.SetSSEHeaders(c)
 	notify := c.Writer.CloseNotify()
 	for i := 0; i < 10; i++ {
 		select {

+ 4 - 6
app/src/composables/useSSE.ts

@@ -28,10 +28,6 @@ export function useSSE() {
    * Connect to SSE service
    */
   function connect(options: SSEOptions) {
-    if (!token.value) {
-      return
-    }
-
     const {
       url,
       onMessage,
@@ -42,8 +38,10 @@ export function useSSE() {
 
     const fullUrl = urlJoin(window.location.pathname, url)
 
-    const headers = {
-      Authorization: token.value,
+    const headers: Record<string, string> = {}
+
+    if (token.value) {
+      headers.Authorization = token.value
     }
 
     if (settings.environment.id) {