Skip to content

Commit

Permalink
feat(dev): add x-forwarded headers (#247)
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
  • Loading branch information
abdullrahman02000 and pi0 authored Jun 12, 2022
1 parent 78bf46a commit 2d50312
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dev/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ export function createDevServer (nitro: Nitro): NitroDevServer {

// Worker proxy
const proxy = httpProxy.createProxy()
proxy.on('proxyReq', (proxyReq, req) => {
// TODO: Avoid overwriting headers if already set
proxyReq.setHeader('X-Forwarded-For', req.socket.remoteAddress)
proxyReq.setHeader('X-Forwarded-Port', req.socket.remotePort)
proxyReq.setHeader('X-Forwarded-Proto', req.socket.remoteFamily)
})
app.use(eventHandler(async (event) => {
await reloadPromise
const address = currentWorker?.address
Expand Down

0 comments on commit 2d50312

Please sign in to comment.