bigskysoftware / bigskysoftware/htmx-extensions

SSE extension: Add the ability to send data to the endpoint before the connecction is being made similar to htmx:configRequest or htmx:wsConfigSend

Open
#132 5 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
284
Forks
88
PR merge metrics
No merged PRs in 30d

Description

I have many users, each user has his own cookie identifier, I need to send to the SSE endpoint in order for the server to perform the right action, on the data belonging to the correct user.

In HTMX I can do this

```
document.body.addEventListener("htmx:configRequest", function (evt) {
evt.detail.headers["cookie"] = cookie;
});
```

I can do the same via was extension via the `htmx:wsConfigSend` event, but in sse, there's no such events and I can't pass data via the headers, I'm forced to append the cookie to the sse URL via javascript and that's so dirty, like so

```

const sseContainer = document.getElementById("sse-container");
sseContainer.setAttribute(
"sse-connect",
"/progress/" + cookie
);

```
I would be great to be able to pass data via the headers and have more control like the standard htmx and websockets extension

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.