fix
This commit is contained in:
parent
ea8a00e2ab
commit
d539647a85
2
.env
2
.env
@ -1 +1 @@
|
||||
API_ENDPOINT=http://192.168.31.115:18080/api
|
||||
API_ENDPOINT=https://api.memorywake.com/api
|
||||
@ -1,6 +1,4 @@
|
||||
// app.config.js
|
||||
console.log("API_ENDPOINT from process.env:", process.env.API_ENDPOINT);
|
||||
|
||||
export default ({ config }) => ({
|
||||
...config,
|
||||
extra: {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { setCredentials } from '@/features/auth/authSlice';
|
||||
import Constants from 'expo-constants';
|
||||
import * as SecureStore from 'expo-secure-store';
|
||||
import { Platform } from 'react-native';
|
||||
import Toast from 'react-native-toast-message';
|
||||
@ -24,7 +25,7 @@ export interface PagedResult<T> {
|
||||
// 获取.env文件中的变量
|
||||
|
||||
|
||||
export const API_ENDPOINT = () => process.env.API_ENDPOINT || "http://192.168.31.115:18080/api";
|
||||
export const API_ENDPOINT = () => Constants.expoConfig?.extra?.API_ENDPOINT || "http://192.168.31.115:18080/api";
|
||||
|
||||
// 更新 access_token 的逻辑 - 用于React组件中
|
||||
export const useAuthToken = async<T>(message: string | null) => {
|
||||
@ -140,7 +141,7 @@ export const fetchApi = async <T>(
|
||||
headers.set('Authorization', `Bearer ${token}`);
|
||||
}
|
||||
|
||||
const url = `${API_ENDPOINT()}/v1${path}`;
|
||||
const url = `${API_ENDPOINT}/v1${path}`;
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
headers,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user