Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
fc19c4cf
authored
Feb 01, 2024
by
Fengrui Liu
Committed by
GitHub
Feb 01, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add IPv6 support for hostnames (#807)
parent
9188752b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
4 deletions
+20
-4
packages/service/support/permission/auth/common.ts
+6
-1
projects/app/src/service/common/api/request.ts
+7
-2
projects/app/src/service/moduleDispatch/tools/http.ts
+7
-1
No files found.
packages/service/support/permission/auth/common.ts
View file @
fc19c4cf
...
@@ -2,6 +2,7 @@ import { AuthUserTypeEnum } from '@fastgpt/global/support/permission/constant';
...
@@ -2,6 +2,7 @@ import { AuthUserTypeEnum } from '@fastgpt/global/support/permission/constant';
import
{
parseHeaderCert
}
from
'../controller'
;
import
{
parseHeaderCert
}
from
'../controller'
;
import
{
AuthModeType
}
from
'../type'
;
import
{
AuthModeType
}
from
'../type'
;
import
{
authOutLinkValid
}
from
'./outLink'
;
import
{
authOutLinkValid
}
from
'./outLink'
;
import
{
isIPv6
}
from
'net'
;
export
const
authCert
=
async
(
props
:
AuthModeType
)
=>
{
export
const
authCert
=
async
(
props
:
AuthModeType
)
=>
{
const
result
=
await
parseHeaderCert
(
props
);
const
result
=
await
parseHeaderCert
(
props
);
...
@@ -34,7 +35,11 @@ export async function authCertOrShareId({
...
@@ -34,7 +35,11 @@ export async function authCertOrShareId({
/* auth the request from local service */
/* auth the request from local service */
export
const
authRequestFromLocal
=
({
req
}:
AuthModeType
)
=>
{
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
)
{
if
(
host
!==
req
.
headers
.
host
)
{
return
Promise
.
reject
(
'Invalid request'
);
return
Promise
.
reject
(
'Invalid request'
);
}
}
...
...
projects/app/src/service/common/api/request.ts
View file @
fc19c4cf
import
axios
,
{
Method
,
InternalAxiosRequestConfig
,
AxiosResponse
}
from
'axios'
;
import
axios
,
{
Method
,
InternalAxiosRequestConfig
,
AxiosResponse
}
from
'axios'
;
import
{
isIPv6
}
from
'net'
;
interface
ConfigType
{
interface
ConfigType
{
headers
?:
{
[
key
:
string
]:
string
};
headers
?:
{
[
key
:
string
]:
string
};
hold
?:
boolean
;
hold
?:
boolean
;
...
@@ -78,7 +78,12 @@ export function request(url: string, data: any, config: ConfigType, method: Meth
...
@@ -78,7 +78,12 @@ export function request(url: string, data: any, config: ConfigType, method: Meth
return
instance
return
instance
.
request
({
.
request
({
baseURL
:
`http://
${
process
.
env
.
HOSTNAME
||
'localhost'
}
:
${
process
.
env
.
PORT
||
3000
}
`
,
baseURL
:
`http://
${
process
.
env
.
HOSTNAME
&&
isIPv6
(
process
.
env
.
HOSTNAME
)
?
`[
${
process
.
env
.
HOSTNAME
}
]:
${
process
.
env
.
PORT
||
3000
}
`
:
`
${
process
.
env
.
HOSTNAME
||
'localhost'
}
:
${
process
.
env
.
PORT
||
3000
}
`
}
`
,
url
,
url
,
method
,
method
,
data
:
[
'POST'
,
'PUT'
].
includes
(
method
)
?
data
:
null
,
data
:
[
'POST'
,
'PUT'
].
includes
(
method
)
?
data
:
null
,
...
...
projects/app/src/service/moduleDispatch/tools/http.ts
View file @
fc19c4cf
...
@@ -3,6 +3,7 @@ import type { ModuleDispatchProps } from '@fastgpt/global/core/module/type.d';
...
@@ -3,6 +3,7 @@ import type { ModuleDispatchProps } from '@fastgpt/global/core/module/type.d';
import
{
ModuleInputKeyEnum
,
ModuleOutputKeyEnum
}
from
'@fastgpt/global/core/module/constants'
;
import
{
ModuleInputKeyEnum
,
ModuleOutputKeyEnum
}
from
'@fastgpt/global/core/module/constants'
;
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
{
flatDynamicParams
}
from
'../utils'
;
import
{
flatDynamicParams
}
from
'../utils'
;
import
{
isIPv6
}
from
'net'
;
export
type
HttpRequestProps
=
ModuleDispatchProps
<
{
export
type
HttpRequestProps
=
ModuleDispatchProps
<
{
[
ModuleInputKeyEnum
.
abandon_httpUrl
]:
string
;
[
ModuleInputKeyEnum
.
abandon_httpUrl
]:
string
;
...
@@ -132,7 +133,12 @@ async function fetchData({
...
@@ -132,7 +133,12 @@ async function fetchData({
}):
Promise
<
Record
<
string
,
any
>>
{
}):
Promise
<
Record
<
string
,
any
>>
{
const
{
data
:
response
}
=
await
axios
<
Record
<
string
,
any
>>
({
const
{
data
:
response
}
=
await
axios
<
Record
<
string
,
any
>>
({
method
,
method
,
baseURL
:
`http://
${
process
.
env
.
HOSTNAME
||
'localhost'
}
:
${
process
.
env
.
PORT
||
3000
}
`
,
baseURL
:
`http://
${
process
.
env
.
HOSTNAME
&&
isIPv6
(
process
.
env
.
HOSTNAME
)
?
`[
${
process
.
env
.
HOSTNAME
}
]:
${
process
.
env
.
PORT
||
3000
}
`
:
`
${
process
.
env
.
HOSTNAME
||
'localhost'
}
:
${
process
.
env
.
PORT
||
3000
}
`
}
`
,
url
,
url
,
headers
:
{
headers
:
{
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment