mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix ip header
This commit is contained in:
1 parent
f5f82cd513
commit
b5a5633b73
2 files changed
+3
-1
No files matched your search
@@ -34,6 +34,7 @@ export default async (ctx: KoaContext, next: Next) => {
|
|||||||
json: (ctx.request.headers.accept || '').includes('application/json'),
|
json: (ctx.request.headers.accept || '').includes('application/json'),
|
||||||
websocket: ctx.request.headers.upgrade === 'websocket',
|
websocket: ctx.request.headers.upgrade === 'websocket',
|
||||||
};
|
};
|
||||||
|
request.ip = request.ip.split(',')[0].trim();
|
||||||
const response: HydroResponse = {
|
const response: HydroResponse = {
|
||||||
body: {},
|
body: {},
|
||||||
type: '',
|
type: '',
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ export default async (ctx, next) => {
|
|||||||
ctx.originalPath = ctx.request.path;
|
ctx.originalPath = ctx.request.path;
|
||||||
ctx.path = ctx.request.path = ctx.request.path.replace(/^\/d\/[^/]+\//, '/');
|
ctx.path = ctx.request.path = ctx.request.path.replace(/^\/d\/[^/]+\//, '/');
|
||||||
const [xff, xhost] = system.getMany(['server.xff', 'server.xhost']);
|
const [xff, xhost] = system.getMany(['server.xff', 'server.xhost']);
|
||||||
const ip = ctx.request.headers[xff?.toLowerCase() || ''] as string || ctx.request.ip;
|
let ip = ctx.request.headers[xff?.toLowerCase() || ''] as string || ctx.request.ip;
|
||||||
|
ip = ip.split(',')[0].trim();
|
||||||
const host = ctx.request.headers[xhost?.toLowerCase() || ''] as string || ctx.request.host;
|
const host = ctx.request.headers[xhost?.toLowerCase() || ''] as string || ctx.request.host;
|
||||||
const header = ctx.request.headers.authorization;
|
const header = ctx.request.headers.authorization;
|
||||||
const sid = header
|
const sid = header
|
||||||
|
|||||||
Reference in new issue
Block a user