Browse Source

Merge pull request #6157 from lolgopher/fix/reverse-proxy

Fixed: Reverse proxy by nocodb
pull/6177/head
աɨռɢӄաօռɢ 1 year ago committed by GitHub
parent
commit
a9daf492d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/nc-gui/components/general/HelpAndSupport.vue
  2. 2
      packages/nc-gui/pages/[projectType]/[projectId]/index.vue
  3. 3
      packages/nc-gui/plugins/jobs.ts
  4. 7
      packages/nc-gui/plugins/tele.ts
  5. 5
      packages/nocodb/src/gateways/socket.gateway.ts
  6. 6
      packages/nocodb/src/modules/jobs/jobs.gateway.ts

2
packages/nc-gui/components/general/HelpAndSupport.vue

@ -10,7 +10,7 @@ const { project } = storeToRefs(useProject())
const route = useRoute()
const openSwaggerLink = () => {
openLink(`/api/v1/db/meta/projects/${route.params.projectId}/swagger`, appInfo.value.ncSiteUrl)
openLink(`./api/v1/db/meta/projects/${route.params.projectId}/swagger`, appInfo.value.ncSiteUrl)
}
</script>

2
packages/nc-gui/pages/[projectType]/[projectId]/index.vue

@ -365,7 +365,7 @@ useEventListener(document, 'keydown', async (e: KeyboardEvent) => {
v-if="isUIAllowed('apiDocs') && !isMobileMode"
v-e="['e:api-docs']"
class="nc-project-menu-item group"
@click.stop="openLink(`/api/v1/db/meta/projects/${route.params.projectId}/swagger`, appInfo.ncSiteUrl)"
@click.stop="openLink(`./api/v1/db/meta/projects/${route.params.projectId}/swagger`, appInfo.ncSiteUrl)"
>
<component :is="iconMap.json" class="group-hover:text-accent" />
{{ $t('activity.account.swagger') }}

3
packages/nc-gui/plugins/jobs.ts

@ -13,9 +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: socketPath,
})
socket.on('connect_error', (e) => {

7
packages/nc-gui/plugins/tele.ts

@ -16,10 +16,13 @@ export default defineNuxtPlugin(async (nuxtApp) => {
try {
if (socket) socket.disconnect()
const url = new URL(appInfo.ncSiteUrl, window.location.href.split(/[?#]/)[0]).href
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, {
socket = io(url.href, {
extraHeaders: { 'xc-auth': token },
path: socketPath,
})
socket.on('connect_error', () => {

5
packages/nocodb/src/gateways/socket.gateway.ts

@ -14,12 +14,17 @@ function getHash(str) {
return crypto.createHash('md5').update(str).digest('hex');
}
const url = new URL(process.env.NC_PUBLIC_URL || `http://localhost:${process.env.PORT || '8080'}/`)
let namespace = url.pathname
namespace += namespace.endsWith("/") ? "" : "/"
@WebSocketGateway({
cors: {
origin: '*',
allowedHeaders: ['xc-auth'],
credentials: true,
},
namespace,
})
@Injectable()
export class SocketGateway implements OnModuleInit {

6
packages/nocodb/src/modules/jobs/jobs.gateway.ts

@ -14,13 +14,17 @@ import { JobEvents } from '../../interface/Jobs';
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
namespace += namespace.endsWith("/") ? "jobs" : "/jobs"
@WebSocketGateway({
cors: {
origin: '*',
allowedHeaders: ['xc-auth'],
credentials: true,
},
namespace: 'jobs',
namespace,
})
export class JobsGateway implements OnModuleInit {
constructor(@Inject('JobsService') private readonly jobsService) {}

Loading…
Cancel
Save