diff --git a/src/pages/content/article/Publish.vue b/src/pages/content/article/Publish.vue index bfe7d0fb..7d5c7696 100644 --- a/src/pages/content/article/Publish.vue +++ b/src/pages/content/article/Publish.vue @@ -12,17 +12,23 @@ interface IData { socket: WebSocket | undefined; inputValue: string; chatValue: string; + id: string; } export default defineComponent({ data(): IData { return { + id: this.$route.params.id.toString(), socket: undefined, inputValue: '', chatValue: '' }; }, mounted() { - this.socket = new WebSocket('ws://localhost:8000/ws/chat/1'); + this.socket = new WebSocket( + `${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}/${window.location.host}/ws/publish/${ + this.id + }?access_token=${this.$store.getters.accessToken}` + ); this.socket.onmessage = this.onMessage; }, methods: { diff --git a/vite.config.ts b/vite.config.ts index f9d3c2c0..eb545011 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,6 +11,11 @@ export default defineConfig({ '/api': { target: 'http://localhost:8000', changeOrigin: true + }, + '/ws': { + target: 'ws://localhost:8000', + changeOrigin: true, + ws: true } } },