feat: add base url utility and update api endpoints
This commit is contained in:
@@ -3,6 +3,7 @@ import { useEffect, useState } from 'react';
|
||||
|
||||
import { Authorization } from '@/constants/authorization';
|
||||
import { getAuthorization } from '@/utils/authorization-util';
|
||||
import { withBaseUrl } from '@/utils/url';
|
||||
|
||||
interface ImageProps {
|
||||
src: string;
|
||||
@@ -15,7 +16,7 @@ const Image = ({ src, preview = false }: ImageProps) => {
|
||||
useEffect(() => {
|
||||
const loadImage = async () => {
|
||||
try {
|
||||
const response = await fetch(src, {
|
||||
const response = await fetch(withBaseUrl(src), {
|
||||
headers: {
|
||||
[Authorization]: getAuthorization(),
|
||||
},
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from '@/hooks/logic-hooks';
|
||||
import { IAnswer } from '@/interfaces/database/chat';
|
||||
import api from '@/utils/api';
|
||||
import { withBaseUrl } from '@/utils/url';
|
||||
import { get, isEmpty, isEqual, trim } from 'lodash';
|
||||
import {
|
||||
ChangeEventHandler,
|
||||
@@ -156,7 +157,7 @@ export const useFetchBackgroundImage = () => {
|
||||
const fetchImage = useCallback(async () => {
|
||||
try {
|
||||
const res = await fetch(
|
||||
'/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=zh-CN',
|
||||
withBaseUrl('/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=zh-CN'),
|
||||
);
|
||||
const ret = await res.json();
|
||||
const url = get(ret, 'images.0.url');
|
||||
|
||||
Reference in New Issue
Block a user