Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#1754] fix(web): fix oauth CORS error (#2062)

CHEYNE8845ddda60bf
diff --git a/web/lib/api/auth/index.js b/web/lib/api/auth/index.js
index 00313f37c9..6fdb04ce57 100644
--- a/web/lib/api/auth/index.js
+++ b/web/lib/api/auth/index.js
@@ -3,8 +3,8 @@
* This software is licensed under the Apache License version 2.
*/
+import axios from 'axios'
import { defHttp } from '@/lib/utils/axios'
-import qs from 'qs'
export const getAuthConfigsApi = () => {
return defHttp.get({
@@ -13,7 +13,9 @@ export const getAuthConfigsApi = () => {
}
export const loginApi = (url, params) => {
- return defHttp.post({
- url: `${url}?${qs.stringify(params)}`
+ return axios({
+ url,
+ method: 'post',
+ params
})
}
diff --git a/web/lib/provider/session.js b/web/lib/provider/session.js
index 762daa7859..5fe559f934 100644
--- a/web/lib/provider/session.js
+++ b/web/lib/provider/session.js
@@ -38,7 +38,7 @@ const AuthProvider = ({ children }) => {
const dispatch = useAppDispatch()
const handleLogin = async params => {
- await dispatch(loginAction({ params, router }))
+ dispatch(loginAction({ params, router }))
}
const handleLogout = () => {
diff --git a/web/lib/store/auth/index.js b/web/lib/store/auth/index.js
index f5a320b7c9..03c6d4d75a 100644
--- a/web/lib/store/auth/index.js
+++ b/web/lib/store/auth/index.js
@@ -50,7 +50,7 @@ export const loginAction = createAsyncThunk('auth/loginAction', async ({ params,
dispatch(setAuthParams(params))
localStorage.setItem('authParams', JSON.stringify(params))
- const url = isProdEnv ? getState().auth.oauthUrl : devOauthUrl
+ const url = getState().auth.oauthUrl
const [err, res] = await to(loginApi(url, params))
@@ -58,7 +58,7 @@ export const loginAction = createAsyncThunk('auth/loginAction', async ({ params,
throw new Error(err)
}
- const { access_token, expires_in } = res
+ const { access_token, expires_in } = res.data
localStorage.setItem('accessToken', access_token)
localStorage.setItem('expiredIn', expires_in)