fix dynamic url
This commit is contained in:
parent
e699eb7359
commit
c73b6e9f00
@ -3,7 +3,18 @@ const clientIdItemKey = 'client-id'
|
|||||||
const accessTokenItemKey = 'ACCESS_TOKEN'
|
const accessTokenItemKey = 'ACCESS_TOKEN'
|
||||||
|
|
||||||
|
|
||||||
const auth = {
|
const auth = {
|
||||||
|
getApiUrl() {
|
||||||
|
let HTTP_URL = ''
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
HTTP_URL = import.meta.env.APP_URL;
|
||||||
|
} else {
|
||||||
|
const host: any = document.querySelector('meta[name="host"]')
|
||||||
|
HTTP_URL = host.getAttribute('content');
|
||||||
|
}
|
||||||
|
return HTTP_URL
|
||||||
|
},
|
||||||
|
|
||||||
getClientId() {
|
getClientId() {
|
||||||
return window.localStorage.getItem(clientIdItemKey)
|
return window.localStorage.getItem(clientIdItemKey)
|
||||||
},
|
},
|
||||||
@ -15,7 +26,7 @@ const auth = {
|
|||||||
getAccessToken() {
|
getAccessToken() {
|
||||||
return window.localStorage.getItem(accessTokenItemKey)
|
return window.localStorage.getItem(accessTokenItemKey)
|
||||||
},
|
},
|
||||||
|
|
||||||
resetToken() {
|
resetToken() {
|
||||||
const token = window.localStorage.getItem(accessTokenItemKey);
|
const token = window.localStorage.getItem(accessTokenItemKey);
|
||||||
if (token) {
|
if (token) {
|
||||||
@ -36,7 +47,7 @@ const auth = {
|
|||||||
window.localStorage.setItem(accessTokenItemKey, accessToken)
|
window.localStorage.setItem(accessTokenItemKey, accessToken)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default auth;
|
export default auth;
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ const HttpCodes = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default new Request({
|
export default new Request({
|
||||||
baseUrl: import.meta.env.APP_URL,
|
baseUrl: Auth.getApiUrl(),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user