mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-23 22:46:35 +01:00
* chore: 🔧 remove client * chore: 🔧 change cookie name * chore: 🔧 remove auth param * chore: 🔧 remove auth components * chore: 🔧 add getaccount query * fix: 🐛 tests * chore: 🔧 get account * chore: 🔧 status check * chore: 🔧 remove log * chore: 🔧 update apollo client * refactor: ♻️ server side props * chore: 🔧 ssr queries * chore: 🔧 more ssr queries * chore: 🔧 type check * chore: 🔧 increase nodeinfo limit Co-authored-by: apotdevin <apotdevincab@gmail.com>
30 lines
726 B
TypeScript
30 lines
726 B
TypeScript
import getConfig from 'next/config';
|
|
|
|
const { serverRuntimeConfig } = getConfig() || {};
|
|
const { nodeEnv } = serverRuntimeConfig || {};
|
|
|
|
export const getIp = (req: any) => {
|
|
if (!req || !req.headers) {
|
|
return '';
|
|
}
|
|
const forwarded = req.headers['x-forwarded-for'];
|
|
const before = forwarded
|
|
? forwarded.split(/, /)[0]
|
|
: req.connection.remoteAddress;
|
|
const ip = nodeEnv === 'development' ? '1.2.3.4' : before;
|
|
return ip;
|
|
};
|
|
|
|
export const getErrorMsg = (error: any[] | string): string => {
|
|
if (typeof error === 'string') {
|
|
return error;
|
|
}
|
|
if (error.length >= 2) {
|
|
return error[1];
|
|
}
|
|
// if (error.length > 2) {
|
|
// return error[2].err?.message || 'Error';
|
|
// }
|
|
|
|
return 'Error';
|
|
};
|