From 1712f81dd80542d98a7ccbe2dc9ce812feed82f4 Mon Sep 17 00:00:00 2001 From: haml-707 <845831435@qq.com> Date: Wed, 30 Aug 2023 16:46:42 +0800 Subject: [PATCH] fix: nginx 404 --- web-ui/deploy/nginx/nginx.conf | 2 +- web-ui/src/api/docs-api.ts | 2 +- web-ui/src/shared/axios/setConfig.ts | 34 ++++++++++++++-------------- web-ui/vite.config.ts | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/web-ui/deploy/nginx/nginx.conf b/web-ui/deploy/nginx/nginx.conf index 25960cb..7531da0 100644 --- a/web-ui/deploy/nginx/nginx.conf +++ b/web-ui/deploy/nginx/nginx.conf @@ -86,7 +86,7 @@ http { location / { add_header Cache-Control no-cache; } - location /api { + location /api/ { proxy_pass https://dsapi.osinfra.cn/; } root /usr/share/nginx/html; diff --git a/web-ui/src/api/docs-api.ts b/web-ui/src/api/docs-api.ts index 3dd8806..485ac5e 100644 --- a/web-ui/src/api/docs-api.ts +++ b/web-ui/src/api/docs-api.ts @@ -7,7 +7,7 @@ interface rankParams { } export function getRank(rankParams: rankParams) { - const url = '/query/issueScore'; + const url = '/api/query/issueScore'; return request .get(url, { params: { diff --git a/web-ui/src/shared/axios/setConfig.ts b/web-ui/src/shared/axios/setConfig.ts index dbb6e6c..8072e35 100644 --- a/web-ui/src/shared/axios/setConfig.ts +++ b/web-ui/src/shared/axios/setConfig.ts @@ -1,17 +1,17 @@ -import type { AxiosStatic } from 'axios'; - -/** - * @param {axios} axios实例 - * @param {config} 自定义配置对象,可覆盖掉默认的自定义配置 - */ -export default (axios: AxiosStatic, config = {}) => { - const defaultConfig = { - baseURL: '/api', - timeout: 20000, - headers: { - 'Content-Type': 'application/json;charset=UTF-8', - }, - }; - Object.assign(axios.defaults, defaultConfig, config); - return axios; -}; +import type { AxiosStatic } from 'axios'; + +/** + * @param {axios} axios实例 + * @param {config} 自定义配置对象,可覆盖掉默认的自定义配置 + */ +export default (axios: AxiosStatic, config = {}) => { + const defaultConfig = { + baseURL: '', + timeout: 20000, + headers: { + 'Content-Type': 'application/json;charset=UTF-8', + }, + }; + Object.assign(axios.defaults, defaultConfig, config); + return axios; +}; diff --git a/web-ui/vite.config.ts b/web-ui/vite.config.ts index 2accb5b..9421e72 100644 --- a/web-ui/vite.config.ts +++ b/web-ui/vite.config.ts @@ -38,8 +38,8 @@ export default defineConfig({ }, server: { proxy: { - '/api': { - target: 'https://dsapi.osinfra.cn', + '/api/': { + target: 'https://dsapi.osinfra.cn/', changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), }, -- Gitee