You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if i want to use custom url path, i'm adding it to the options object like: path: '/keka',
but in the request url getting /keka/?
anyone manage this issue?
Reacted by Chris Weber, dummydamn, brianmayer and Jan Kaifer
When I use another domain (which is different than my current domain) for example http://localhost:3000, it automatically adds the trailing slash at the end:
Everything seems to be working so far, but when I use my current domain as the host, it automatically removes the trailingSlash at the end and the result is this one http://example.com/socket.io?EIO=4&transport=polling&t=OrLbF-I
and then it tries to add the trailing slash like this: http://example.com/socket.io/?EIO=4&transport=polling&t=OrLbF-I which results to an 308 Permanent Redirect
That's how my configuration looks like:
import { io } from 'socket.io-client';
// obviously I want to use my current domain
export const socket = (url: string) =>
io({
addTrailingSlash: true,
});
Activity
dummydamn commentedon Sep 8, 2022
I am having the same issue as well
darrachequesne commentedon Sep 9, 2022
Hi! The trailing slash is added there: https://github.com/socketio/engine.io-client/blob/dfee8ded722a8c4f9f773505d0c77b4561569863/lib/socket.ts#L335 (initial commit from 2012: socketio/engine.io-client@93605fd)
I guess we could add an option to include it or not. Could you please explain your use case?
Stoikiy commentedon Sep 13, 2022
if that will be optional in the settings that will be good
feat: add the "addTrailingSlash" option (#694)
griffins commentedon Jan 16, 2023
ping
iifawzi commentedon Jan 16, 2023
The option is already added at socketio/engine.io-client@21a6e12
darrachequesne commentedon Feb 16, 2023
Update: the
addTrailingSlashoption was added in version 4.6.0:Reference: https://socket.io/docs/v4/client-options/#addtrailingslash
Please reopen if needed!
necm1 commentedon Jan 29, 2024
Following issue:
When I use another domain (which is different than my current domain) for example
http://localhost:3000, it automatically adds the trailing slash at the end:http://localhost:3000/socket.io/?EIO=4&transport=polling&t=OrLbOzA&sid=wvjsDtRlP2_P_VulAAAMEverything seems to be working so far, but when I use my current domain as the host, it automatically removes the trailingSlash at the end and the result is this one
http://example.com/socket.io?EIO=4&transport=polling&t=OrLbF-Iand then it tries to add the trailing slash like this:
http://example.com/socket.io/?EIO=4&transport=polling&t=OrLbF-Iwhich results to an308 Permanent RedirectThat's how my configuration looks like:
darrachequesne commentedon Jan 29, 2024
Hi @necm1 , do you know which component returns the HTTP 308 response? nginx?
The
addTrailingSlashindeed controls whether a trailing slash is added in the request path:true=> http://example.com/socket.io/?EIO=4&...false=> http://example.com/socket.io?EIO=4&...necm1 commentedon Jan 29, 2024
I guess NextJS SSR seems to give me the HTTP 308 response (https://nextjs.org/docs/app/api-reference/next-config-js/trailingSlash). I'm using NextJS SSR rewrites as a proxy to my real NestJS backend. I just set
addTrailingSlashtofalsein my backend and it seems to be working now.Sorry for reopening this issue. I was just confused and thought that
socket.io-clientremoves the trailing slash for the current domain.