mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
Add IPv6 support for hostnames (#807)
This commit is contained in:
@@ -2,6 +2,7 @@ import { AuthUserTypeEnum } from '@fastgpt/global/support/permission/constant';
|
||||
import { parseHeaderCert } from '../controller';
|
||||
import { AuthModeType } from '../type';
|
||||
import { authOutLinkValid } from './outLink';
|
||||
import { isIPv6 } from 'net';
|
||||
|
||||
export const authCert = async (props: AuthModeType) => {
|
||||
const result = await parseHeaderCert(props);
|
||||
@@ -34,7 +35,11 @@ export async function authCertOrShareId({
|
||||
|
||||
/* auth the request from local service */
|
||||
export const authRequestFromLocal = ({ req }: AuthModeType) => {
|
||||
const host = `${process.env.HOSTNAME || 'localhost'}:${process.env.PORT || 3000}`;
|
||||
const host =
|
||||
process.env.HOSTNAME && isIPv6(process.env.HOSTNAME)
|
||||
? `[${process.env.HOSTNAME}]:${process.env.PORT || 3000}`
|
||||
: `${process.env.HOSTNAME || 'localhost'}:${process.env.PORT || 3000}`;
|
||||
|
||||
if (host !== req.headers.host) {
|
||||
return Promise.reject('Invalid request');
|
||||
}
|
||||
|
Reference in New Issue
Block a user