From 1c3dbf7318df4bc9a11ad9fb318892668c2921b4 Mon Sep 17 00:00:00 2001 From: lolgopher Date: Fri, 11 Aug 2023 17:15:23 +0900 Subject: [PATCH] fix: url ensure trailing slash --- packages/nocodb/src/gateways/socket.gateway.ts | 7 ++++++- packages/nocodb/src/modules/jobs/jobs.gateway.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/gateways/socket.gateway.ts b/packages/nocodb/src/gateways/socket.gateway.ts index d493d2044e..1cc1b6818d 100644 --- a/packages/nocodb/src/gateways/socket.gateway.ts +++ b/packages/nocodb/src/gateways/socket.gateway.ts @@ -15,13 +15,18 @@ 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 + '/'; +} + @WebSocketGateway({ cors: { origin: '*', allowedHeaders: ['xc-auth'], credentials: true, }, - namespace: url.pathname, + 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 95d4e9fd40..f4f38851f0 100644 --- a/packages/nocodb/src/modules/jobs/jobs.gateway.ts +++ b/packages/nocodb/src/modules/jobs/jobs.gateway.ts @@ -15,13 +15,20 @@ import type { OnModuleInit } from '@nestjs/common'; 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'; +} + @WebSocketGateway({ cors: { origin: '*', allowedHeaders: ['xc-auth'], credentials: true, }, - namespace: `${url.pathname}jobs`, + namespace: namespace, }) export class JobsGateway implements OnModuleInit { constructor(@Inject('JobsService') private readonly jobsService) {}