Skip to content

Commit

Permalink
Merge pull request #253 from da7a90-backup/websocket-cors-fix
Browse files Browse the repository at this point in the history
Fix: fixed websocket connection
  • Loading branch information
gagansuie authored Feb 7, 2023
2 parents ea5a02e + e3be791 commit d9d2587
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function send({
const res = await fetch(`${base}/${path}`, opts)
if (res.ok || res.status === 422) {
const text = await res.text()
if (path === 'wsinit/wsid') return text
if (path === 'wsinit/wsid'|| path.includes('wsinit/channelid')) return text
return text ? JSON.parse(text) : {}
}

Expand Down
2 changes: 1 addition & 1 deletion src/routes/channel/[channelId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
let showDrawer = false
onMount(async () => {
const channelSocketId = get(`wsinit/wsid`)
const channelSocketId = await get(`wsinit/channelid?channelId=${data.post._id}`)
const channelSocket = new WebSocket(
`${env.PUBLIC_WEBSOCKET_URL}/wsinit/channelid/${channelSocketId}/connect`
)
Expand Down

0 comments on commit d9d2587

Please sign in to comment.