fix dynamic url

This commit is contained in:
umono 2022-12-19 21:04:47 +08:00
parent e699eb7359
commit c73b6e9f00
2 changed files with 15 additions and 4 deletions

View File

@ -3,7 +3,18 @@ const clientIdItemKey = 'client-id'
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() {
return window.localStorage.getItem(clientIdItemKey)
},

View File

@ -11,7 +11,7 @@ const HttpCodes = {
}
export default new Request({
baseUrl: import.meta.env.APP_URL,
baseUrl: Auth.getApiUrl(),
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'