Skip to content

Server-Sent Event (SSE) not working on Safari #394

Description

@jerrygzy

hi, been trying the v4.7.4 , I am getting a error

u.local/:1 EventSource's response has a MIME type ("text/plain") that is not "text/event-stream". Aborting the connection.

Screenshot From 2025-01-27 20-47-38

index.html

<!DOCTYPE html>
<head>
  <script src="https://unpkg.com/htmx.org@2.0.4"></script>
  <script src="https://unpkg.com/htmx-ext-sse@2.2.2/sse.js"></script>
  <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 min-h-screen p-8 text-center">
  <!-- Current Time by SSE -->
  <div id="current-time"
        class="message time-event"
        hx-ext="sse"
        sse-connect="/events"
        sse-swap="time">
      Waiting for time update...
  </div>
</body>

main.nim

  sse "/events":
    while true:
      let now = now().utc.format("ddd, d MMM yyyy HH:mm:ss")
      await req.sseSend("time", now)
      await sleepAsync(2500)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions