Fix CORS issue
This commit is contained in:
parent
f55b202014
commit
a63661a088
7 changed files with 584 additions and 20 deletions
|
@ -2,8 +2,12 @@ import { Server } from 'socket.io'
|
|||
import { backendProxy } from '../lib/db/db.js'
|
||||
|
||||
function configureServer(server) {
|
||||
const io = new Server(server.httpServer)
|
||||
|
||||
const io = new Server(server, {
|
||||
cors: {
|
||||
origin: '*',
|
||||
}
|
||||
});
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
socket.on('join', async (id) => {
|
||||
socket.join(id);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<script>
|
||||
import { io } from 'socket.io-client'
|
||||
import { dev } from '$app/environment';
|
||||
import PostBody from '$lib/components/PostBody.svelte';
|
||||
|
||||
/** @type {import('./$types').PageData} */
|
||||
|
@ -9,13 +10,21 @@
|
|||
let messages = [];
|
||||
let input;
|
||||
|
||||
const socket = io();
|
||||
let socket;
|
||||
|
||||
if (dev) {
|
||||
socket = io('http://localhost:7272/');
|
||||
} else {
|
||||
socket = io('http://ws.tdgmdev.net/');
|
||||
}
|
||||
|
||||
|
||||
socket.emit('join',id);
|
||||
|
||||
function scroll() {
|
||||
setTimeout(function() {
|
||||
input.lastChild.scrollIntoView()
|
||||
if (input && input.lastChild)
|
||||
input.lastChild.scrollIntoView()
|
||||
},200);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue