Skip to content

Commit

Permalink
Merge pull request #1229 from luofann/fix_fe_test
Browse files Browse the repository at this point in the history
upd: init接口兼容首页访问url不以/结尾的情况
  • Loading branch information
luofann authored Nov 13, 2023
2 parents 413e2c4 + 7d34cb1 commit 4a4a092
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/pc/src/utils/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ bus.$on('processData', (response) => {
*/
instance.interceptors.request.use(
(config) => {
if (config.url === 'init/') {
// 接口请求如果已经配置了以SITE_URL开头,则不需要添加baseURL
if (new RegExp(`^${SITE_URL}`).test(config.url)) {
config.baseURL = '';
}
// 添加工单查看权限
Expand All @@ -82,7 +83,7 @@ instance.interceptors.request.use(

instance.interceptors.response.use(
(response) => {
if (response.config.url === 'init/') {
if (response.config.url === `${SITE_URL}init/`) {
if (response.status === 401) {
const { login_url } = response.data;
const url = `${login_url.split('c_url=')[0]}c_url=${encodeURIComponent(location.href)}`;
Expand Down

0 comments on commit 4a4a092

Please sign in to comment.