New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace XMLHttpRequest
with fetch
#4980
Labels
enhancement
New feature or request
Comments
We could indeed provide another implementation for the HTTP long-polling transport, something like: import { io } from "socket.io-client";
const socket = io({
transports: [
PollingWithFetch,
WebSocket
]
}); Related: socketio/engine.io-client#716 |
darrachequesne
added a commit
to socketio/engine.io-client
that referenced
this issue
Apr 23, 2024
Usage: ```js import { Socket, transports, Fetch } from "engine.io-client"; transports.polling = Fetch; const socket = new Socket("https://example.com"); ``` Note: tree-shaking unused transports is not currently supported and will be added later. Related: - socketio/socket.io#4980 - #716
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
Currently, socket.io can't be used in Chrome extension background script, since modern Manifest V3 extensions are using service worker as a background script (which doesn't have
XMLHttpRequest
, onlyfetch
).Example error:
Describe the solution you'd like
Replacing
XMLHttpRequest
with modernfetch
.Describe alternatives you've considered
I think using
transports: ['websocket'],
would help, but that way I can't useextraHeaders
which I use for authorization.Additional context
The text was updated successfully, but these errors were encountered: