Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VCCI-News
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Văn Hoàng
VCCI-News
Commits
88ac0a9e
Commit
88ac0a9e
authored
Jun 16, 2026
by
Lê Bảo Hồng Đức
☄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
70a14928
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
14 deletions
+40
-14
next.config.ts
next.config.ts
+4
-4
index.ts
src/links/index.ts
+36
-10
No files found.
next.config.ts
View file @
88ac0a9e
...
...
@@ -22,15 +22,15 @@ const nextConfig: NextConfig = {
},
{
protocol
:
"https"
,
hostname
:
"vccihcm.vn"
,
hostname
:
"
news.
vccihcm.vn"
,
port
:
""
,
pathname
:
"/
image
s/**"
,
pathname
:
"/
upload
s/**"
,
},
{
protocol
:
"https"
,
hostname
:
"
news.
vccihcm.vn"
,
hostname
:
"vccihcm.vn"
,
port
:
""
,
pathname
:
"/
upload
s/**"
,
pathname
:
"/
image
s/**"
,
},
],
},
...
...
src/links/index.ts
View file @
88ac0a9e
...
...
@@ -22,6 +22,26 @@ const extractUploadPath = (pathname: string) => {
return
null
;
};
const
normalizeUploadPath
=
(
pathname
:
string
)
=>
{
if
(
pathname
.
includes
(
"/api/uploads/"
))
{
return
pathname
.
replace
(
/^.*
\/
api
\/
uploads
\/
/
,
"/uploads/"
);
}
if
(
pathname
.
includes
(
"/images/"
))
{
return
pathname
.
replace
(
/^.*
\/
images
\/
/
,
"/uploads/images/"
);
}
if
(
pathname
.
includes
(
"/uploads/"
))
{
return
pathname
.
replace
(
/^.*
\/
uploads
\/
/
,
"/uploads/"
);
}
if
(
pathname
.
includes
(
"/wp-content/uploads/"
))
{
return
pathname
.
replace
(
/^.*
\/
wp-content
\/
uploads
\/
/
,
"/uploads/"
);
}
return
pathname
;
};
const
readOrigin
=
(
key
:
"NEXT_PUBLIC_BACKEND_HOST"
|
"NEXT_PUBLIC_FRONTEND_HOST"
)
=>
{
const
envOrigin
=
normalizeOrigin
(
key
===
"NEXT_PUBLIC_BACKEND_HOST"
...
...
@@ -71,18 +91,19 @@ export const resolveUploadUrl = (value?: string | null) => {
const
trimmed
=
value
?.
trim
();
if
(
!
trimmed
)
return
""
;
if
(
trimmed
.
startsWith
(
"http://"
)
||
trimmed
.
startsWith
(
"https://"
)
||
trimmed
.
startsWith
(
"blob:"
)
||
trimmed
.
startsWith
(
"data:"
)
)
{
if
(
trimmed
.
startsWith
(
"blob:"
)
||
trimmed
.
startsWith
(
"data:"
))
{
return
trimmed
;
}
if
(
/^https
?
:
\/\/
/i
.
test
(
trimmed
))
{
try
{
const
url
=
new
URL
(
trimmed
);
const
normalizedPath
=
normalizeUploadPath
(
url
.
pathname
);
if
(
normalizedPath
!==
url
.
pathname
)
{
return
backendOrigin
?
`
${
backendOrigin
}${
normalizedPath
}
`
:
normalizedPath
;
}
if
(
LEGACY_MEDIA_HOSTS
.
has
(
url
.
hostname
))
{
const
uploadPath
=
extractUploadPath
(
url
.
pathname
);
if
(
uploadPath
)
{
...
...
@@ -100,17 +121,22 @@ export const resolveUploadUrl = (value?: string | null) => {
if
(
trimmed
.
startsWith
(
"/uploads/"
)
||
trimmed
.
startsWith
(
"/api/uploads/"
)
||
trimmed
.
startsWith
(
"/images/"
)
trimmed
.
startsWith
(
"/images/"
)
||
trimmed
.
startsWith
(
"/wp-content/uploads/"
)
)
{
const
cleanPath
=
trimmed
.
replace
(
/^
\/
+/
,
""
).
replace
(
/^api
\/
uploads
\/
/
,
"uploads/
"
);
const
cleanPath
=
normalizeUploadPath
(
trimmed
).
replace
(
/^
\/
+/
,
"
"
);
return
backendOrigin
?
`
${
backendOrigin
}
/
${
cleanPath
}
`
:
`/
${
cleanPath
}
`
;
}
return
trimmed
;
}
const
cleanPath
=
trimmed
.
replace
(
/^
\/
+/
,
""
).
replace
(
/^api
\/
uploads
\/
/
,
"uploads/"
);
if
(
cleanPath
.
startsWith
(
"uploads/"
)
||
cleanPath
.
startsWith
(
"images/"
))
{
const
cleanPath
=
normalizeUploadPath
(
trimmed
).
replace
(
/^
\/
+/
,
""
);
if
(
cleanPath
.
startsWith
(
"uploads/"
)
||
cleanPath
.
startsWith
(
"images/"
)
||
cleanPath
.
startsWith
(
"wp-content/uploads/"
)
)
{
return
backendOrigin
?
`
${
backendOrigin
}
/
${
cleanPath
}
`
:
`/
${
cleanPath
}
`
;
}
...
...
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