Skip to content

Instantly share code, notes, and snippets.

@Tsugami
Created September 20, 2024 15:54
Show Gist options
  • Select an option

  • Save Tsugami/b4c5dbf3b4cf6185b1f6643d6734e84f to your computer and use it in GitHub Desktop.

Select an option

Save Tsugami/b4c5dbf3b4cf6185b1f6643d6734e84f to your computer and use it in GitHub Desktop.

Revisions

  1. Tsugami created this gist Sep 20, 2024.
    9,736 changes: 9,736 additions & 0 deletions eventsource-polyfill.js
    9,736 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
    35 changes: 35 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    </head>
    <body>
    arroz
    <script src=/eventsource-polyfill.js></script>

    <script>
    const id = `44869422808`;
    const url = `https://xxx/auth/${id}/face-match/events`;
    const token = 'xxxx';

    const authorization = `Bearer ${token}`;

    const source = new EventSourcePolyfill(url, {
    // withCredentials: true,
    headers: {
    Authorization: authorization,
    },
    });

    source.onmessage = function(event) {
    console.log(event);
    };

    source.onerror = function(error) {
    console.error(error);
    };
    </script>
    </body>
    </html>