server
Advanced tools
Comparing version 1.0.36 to 1.0.37
{ | ||
"name": "server", | ||
"version": "1.0.36", | ||
"version": "1.0.37", | ||
"description": "A modern and powerful server for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://serverjs.io/", |
@@ -94,2 +94,11 @@ // Parser plugin | ||
}, | ||
// Fix the IP for heroku and similars | ||
ctx => { | ||
const forwarded = ctx.headers['x-forwarded-for']; | ||
if (!forwarded) return; | ||
const ip = forwarded.trim().split(/,\s?/g).shift(); | ||
Object.defineProperty(ctx, 'ip', { enumerable: true, value: ip }); | ||
}, | ||
] | ||
@@ -96,0 +105,0 @@ }; |
@@ -59,2 +59,14 @@ // External libraries used | ||
// Can overwrite the IP | ||
it.only('method-override through header', async () => { | ||
const mid = ctx => { | ||
expect(ctx.ip).toBe('123.123.123.123'); | ||
return 'Hello 世界'; | ||
}; | ||
const headers = { 'X-Forwarded-For': '123.123.123.123, 111.111.111.111' }; | ||
const res = await run(mid).post('/', { headers }); | ||
expect(res.body).toBe('Hello 世界'); | ||
}); | ||
// Change the method to the specified one | ||
@@ -61,0 +73,0 @@ it('override-method works with a string', async () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
805634
4093
161