client: proxy websocket when running deno task dev
This commit is contained in:
parent
d78db0448c
commit
baa289f91c
3 changed files with 21 additions and 1 deletions
|
|
@ -4,5 +4,12 @@
|
|||
"build": "deno run -A npm:vite build",
|
||||
"preview": "deno run -A npm:vite preview",
|
||||
"serve": "deno run --allow-net --allow-read https://deno.land/std@0.157.0/http/file_server.ts dist/"
|
||||
},
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom",
|
||||
"dom.iterable"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import './style.css'
|
|||
|
||||
const presenceInfo = document.querySelector<HTMLDivElement>('#presence-info')!
|
||||
const canvas = document.querySelector<HTMLCanvasElement>('#canvas')!
|
||||
const socket = new WebSocket(`${window.location.protocol.replace('http', 'ws')}//${window.location.hostname}/server`)
|
||||
const socket = new WebSocket(`${window.location.protocol.replace('http', 'ws')}//${window.location.host}/server`)
|
||||
|
||||
type Message =
|
||||
| { type: 'presence-information', others: number }
|
||||
|
|
|
|||
13
client/vite.config.js
Normal file
13
client/vite.config.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { defineConfig } from 'vite'
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
proxy: {
|
||||
'/server': {
|
||||
target: 'ws://127.0.0.1:5174',
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue