Skip to content

Commit 747823c

Browse files
committed
feat: local api url
1 parent 1aeefb8 commit 747823c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/pages/article/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ const Article = (data) => {
2929
]
3030
const {title, description, keywords} = seo || {};
3131
const sortTag = tagList?.find(item => item.key === tag_type)?.label;
32+
const env = process.env.NODE_ENV || 'development';
33+
const fetchUrl = env === 'development' ? 'http://localhost:3002' : '';
3234

3335
useEffect(() => {
3436
setMobile(isMobile(window));
35-
fetch('/api/getTagList')
37+
fetch(`${fetchUrl}/api/getTagList`)
3638
.then(res => res.json())
3739
.then(res => {
3840
const tagList = res.data?.map((item) => {
@@ -75,7 +77,7 @@ const Article = (data) => {
7577
sort_type,
7678
}
7779
setSpinning(true)
78-
fetch(`/api/getArticleList?${new URLSearchParams(params).toString()}`)
80+
fetch(`${fetchUrl}/api/getArticleList?${new URLSearchParams(params).toString()}`)
7981
.then(res => res.json())
8082
.then(res => {
8183
handleArticleList(res.data)

0 commit comments

Comments
 (0)