Browse Source

cors + fixes

Ivan Asmer 6 years ago
parent
commit
fb6a1db750
2 changed files with 4 additions and 1 deletions
  1. 2 0
      index.js
  2. 2 1
      public/js/index.js

+ 2 - 0
index.js

@@ -1,9 +1,11 @@
 const express = require('express');
+const cors    = require('cors')
 var app  = express()
 var http = require('http').Server(app);
 var io = require('socket.io')(http);
 
 app.use(express.static('public'))
+app.use(cors())
 
 let gamers = []
 

+ 2 - 1
public/js/index.js

@@ -6,7 +6,8 @@ let startGame = id => socket.emit('startGame', {id})
 
 connect.onchange = () => ({
     true(){
-        socket = io() //connect
+        socket = io('http://localhost:4000') //connect
+        //socket = io() //connect
         socket.on('hi',({id}) => ourId = id) //our id from serverside 
         socket.emit('conn', {nick: nick.value}) //our nick to  serverside