Skip to content

Commit

Permalink
Merge pull request #22 from Crazy-Cow/CD-72
Browse files Browse the repository at this point in the history
fix: socket cors 설정 [CD-72]
  • Loading branch information
ddubbu-dev authored Nov 15, 2024
2 parents 8dcca4e + 51ce2ee commit be72dc0
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,10 @@ import routes from './routes'
import swaggerUi from 'swagger-ui-express'
import swaggerDocument from './docs/swagger-output.json'
import { initSocket } from './socket'
import { Server, ServerOptions } from 'socket.io'
import { Server } from 'socket.io'
import { initInGmaeSocket } from './game/server'

const port = process.env.PORT
const socketClientUrl = process.env.SOCKET_CLIENT_URL
const socketCorsOption: Partial<ServerOptions> = {
cors: {
origin: socketClientUrl,
methods: ['GET', 'POST'],
credentials: true,
},
transports: ['websocket', 'polling'],
}

const app: Express = express()
app.use(cors())
Expand All @@ -35,7 +26,7 @@ const server = app.listen(port, () => {
console.log(`[2] Server runs at <http://localhost>:${port}`)
})

const io = new Server(server, socketCorsOption)
const io = new Server(server, { cors: { origin: '*' } })
initSocket(io)
initInGmaeSocket(io)

Expand Down

0 comments on commit be72dc0

Please sign in to comment.