diff --git a/packages/nc-gui/plugins/jobs.ts b/packages/nc-gui/plugins/jobs.ts index 2df588160c..116c2399e1 100644 --- a/packages/nc-gui/plugins/jobs.ts +++ b/packages/nc-gui/plugins/jobs.ts @@ -13,10 +13,12 @@ export default defineNuxtPlugin(async (nuxtApp) => { if (socket) socket.disconnect() const url = new URL(appInfo.ncSiteUrl, window.location.href.split(/[?#]/)[0]) + let socketPath = url.pathname + socketPath += socketPath.endsWith("/") ? "socket.io" : "/socket.io" socket = io(`${url.href}jobs`, { extraHeaders: { 'xc-auth': token }, - path: `${url.pathname}socket.io`, + path: socketPath, }) socket.on('connect_error', (e) => { diff --git a/packages/nc-gui/plugins/tele.ts b/packages/nc-gui/plugins/tele.ts index 87dc91cc2c..a28a9dd3be 100644 --- a/packages/nc-gui/plugins/tele.ts +++ b/packages/nc-gui/plugins/tele.ts @@ -17,10 +17,12 @@ export default defineNuxtPlugin(async (nuxtApp) => { if (socket) socket.disconnect() const url = new URL(appInfo.ncSiteUrl, window.location.href.split(/[?#]/)[0]) + let socketPath = url.pathname + socketPath += socketPath.endsWith("/") ? "socket.io" : "/socket.io" socket = io(url.href, { extraHeaders: { 'xc-auth': token }, - path: `${url.pathname}socket.io`, + path: socketPath, }) socket.on('connect_error', () => { diff --git a/packages/nocodb/src/gateways/socket.gateway.ts b/packages/nocodb/src/gateways/socket.gateway.ts index 1cc1b6818d..14f5071f9a 100644 --- a/packages/nocodb/src/gateways/socket.gateway.ts +++ b/packages/nocodb/src/gateways/socket.gateway.ts @@ -16,9 +16,7 @@ function getHash(str) { const url = new URL(process.env.NC_PUBLIC_URL || `http://localhost:${process.env.PORT || '8080'}/`) let namespace = url.pathname -if (!namespace.endsWith('/')) { - namespace = namespace + '/'; -} +namespace += namespace.endsWith("/") ? "" : "/" @WebSocketGateway({ cors: { @@ -26,7 +24,7 @@ if (!namespace.endsWith('/')) { allowedHeaders: ['xc-auth'], credentials: true, }, - namespace: namespace, + namespace, }) @Injectable() export class SocketGateway implements OnModuleInit { diff --git a/packages/nocodb/src/modules/jobs/jobs.gateway.ts b/packages/nocodb/src/modules/jobs/jobs.gateway.ts index f4f38851f0..76ababf3c2 100644 --- a/packages/nocodb/src/modules/jobs/jobs.gateway.ts +++ b/packages/nocodb/src/modules/jobs/jobs.gateway.ts @@ -16,11 +16,7 @@ import type { JobStatus } from '../../interface/Jobs'; const url = new URL(process.env.NC_PUBLIC_URL || `http://localhost:${process.env.PORT || '8080'}/`) let namespace = url.pathname -if (!namespace.endsWith('/')) { - namespace = namespace + '/jobs'; -} else { - namespace = namespace + 'jobs'; -} +namespace += namespace.endsWith("/") ? "jobs" : "/jobs" @WebSocketGateway({ cors: { @@ -28,7 +24,7 @@ if (!namespace.endsWith('/')) { allowedHeaders: ['xc-auth'], credentials: true, }, - namespace: namespace, + namespace, }) export class JobsGateway implements OnModuleInit { constructor(@Inject('JobsService') private readonly jobsService) {}