Browse Source

fix: code review

pull/6157/head
lolgopher 1 year ago
parent
commit
bb616a5ec7
  1. 4
      packages/nc-gui/plugins/jobs.ts
  2. 4
      packages/nc-gui/plugins/tele.ts
  3. 6
      packages/nocodb/src/gateways/socket.gateway.ts
  4. 8
      packages/nocodb/src/modules/jobs/jobs.gateway.ts

4
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) => {

4
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', () => {

6
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 {

8
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) {}

Loading…
Cancel
Save