fix and refactor websocket

This commit is contained in:
Henry Jameson 2026-06-24 19:38:39 +03:00
commit 354f35c690
5 changed files with 22 additions and 177 deletions

View file

@ -73,6 +73,7 @@ export default defineConfig(async ({ mode, command }) => {
const settings = await getLocalDevSettings()
const target = settings.target || 'http://localhost:4000/'
const origin = settings.origin || target
const targetSW = target.replace(/^http/,'ws')
const transformSW = getTransformSWSettings(settings)
const proxy = {
'/api': {
@ -80,6 +81,7 @@ export default defineConfig(async ({ mode, command }) => {
changeOrigin: true,
cookieDomainRewrite: 'localhost',
ws: true,
rewriteWsOrigin: true,
},
'/auth': {
// Mastodon password reset lives here
@ -98,20 +100,21 @@ export default defineConfig(async ({ mode, command }) => {
changeOrigin: true,
cookieDomainRewrite: 'localhost',
},
'/socket': {
target,
changeOrigin: true,
cookieDomainRewrite: 'localhost',
ws: true,
headers: {
Origin: origin,
},
},
'/oauth': {
target,
changeOrigin: true,
cookieDomainRewrite: 'localhost',
},
'/socket': {
target: targetSW,
changeOrigin: true,
cookieDomainRewrite: 'localhost',
rewriteWsOrigin: true,
ws: true,
headers: {
Origin: origin,
},
},
}
const swSrc = 'src/sw.js'