Skip to content

Commit

Permalink
Fix: apply base path to client and websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
sandreas authored and 1nVitr0 committed Apr 25, 2023
1 parent dadd41c commit 7e59c6e
Show file tree
Hide file tree
Showing 6 changed files with 567 additions and 11 deletions.
7 changes: 4 additions & 3 deletions client/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="text-white max-h-screen h-screen overflow-hidden bg-bg">
<div class="h-screen max-h-screen overflow-hidden text-white bg-bg">
<app-appbar />

<app-side-rail v-if="isShowingSideRail" class="hidden md:block" />
Expand Down Expand Up @@ -97,7 +97,7 @@ export default {
this.isFirstSocketConnection = false
this.isSocketConnected = true
},
connectError() {
connectError (e) {
console.error('[SOCKET] connect error')
this.updateSocketConnectionToast(this.$strings.ToastSocketFailedToConnect, 'error', null)
},
Expand Down Expand Up @@ -368,14 +368,15 @@ export default {
initializeSocket() {
this.socket = this.$nuxtSocket({
name: process.env.NODE_ENV === 'development' ? 'dev' : 'prod',
channel: this.$config.routerBasePath,
persist: 'main',
teardown: false,
transports: ['websocket'],
upgrade: false,
reconnection: true
})
this.$root.socket = this.socket
console.log('Socket initialized')
console.log('Socket initialized', this.socket)
// Pre-defined socket events
this.socket.on('connect', this.connect)
Expand Down
4 changes: 4 additions & 0 deletions client/plugins/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export default function ({ $axios, store, $config }) {
config.url = `/dev${config.url}`
console.log('Making request to ' + config.url)
}

if ($config.routerBasePath) {
config.url = `${$config.routerBasePath}/${config.url}`
}
})

$axios.onError(error => {
Expand Down
Loading

0 comments on commit 7e59c6e

Please sign in to comment.