Skip to content

Commit

Permalink
log network errors instead #1269
Browse files Browse the repository at this point in the history
  • Loading branch information
SnosMe committed Jan 24, 2024
1 parent d1299e3 commit fd80460
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ app.on('ready', async () => {
const gameConfig = new GameConfig(eventPipe, logger)
const poeWindow = new GameWindow()
const appUpdater = new AppUpdater(eventPipe)
const httpProxy = new HttpProxy(server)
const httpProxy = new HttpProxy(server, logger)

setTimeout(
async () => {
Expand Down
8 changes: 7 additions & 1 deletion main/src/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Server } from 'http'
import * as https from 'https'
import { app } from 'electron'
import type { Logger } from './RemoteLogger'

export const PROXY_HOSTS = [
{ host: 'www.pathofexile.com', official: true },
Expand All @@ -15,7 +16,8 @@ export class HttpProxy {
cookiesForPoe = new Map<string, string>()

constructor (
server: Server
server: Server,
logger: Logger
) {
server.addListener('request', (req, res) => {
if (!req.url?.startsWith('/proxy/')) return
Expand Down Expand Up @@ -44,6 +46,10 @@ export class HttpProxy {
res.writeHead(proxyRes.statusCode!, proxyRes.statusMessage!, proxyRes.rawHeaders)
proxyRes.pipe(res)
})
proxyReq.addListener('error', (err) => {
logger.write(`error [cors-proxy] ${err.message}`)
res.destroy(err)
})
req.pipe(proxyReq)
})
}
Expand Down

0 comments on commit fd80460

Please sign in to comment.