Skip to content

Commit

Permalink
Merge pull request #146 from PokemonGoers/websocket-proxy-fix
Browse files Browse the repository at this point in the history
Websocket proxy
  • Loading branch information
Jochen Hartl authored Oct 23, 2016
2 parents 08e61fe + 53827c8 commit c072b3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"dependencies": {
"compression": "^1.6.2",
"express": "^4.14.0",
"express-http-proxy": "^0.10.0",
"http-proxy-middleware": "^0.17.2",
"morgan": "^1.7.0"
}
}
10 changes: 3 additions & 7 deletions server/pokemon-server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const express = require('express')
const path = require('path')
const http = require('http')
const proxy = require('express-http-proxy')
const proxy = require('http-proxy-middleware')
const compression = require('compression')
const logger = require('morgan')

Expand All @@ -21,14 +21,10 @@ class PokemonServer {
app.use(express.static(path.join(__dirname, 'app'), {maxage: 7 * 86400000}))

// Proxy requests to /api to API backend
app.use('/api', proxy(config.apiEndpoint, {
forwardPath: (req, res) => req.originalUrl
}))
app.use('/api', proxy(config.apiEndpoint))

// Proxy websocket requests to API backend
app.use('/socket.io', proxy(config.websocketEndpoint, {
forwardPath: (req, res) => req.originalUrl
}))
app.use('/socket.io', proxy(config.websocketEndpoint, {ws: true}))

this._app = app

Expand Down

0 comments on commit c072b3f

Please sign in to comment.