mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
refactor: add env variables for easier development (#204)
Co-authored-by: Viren070 <viren070@protonmail.com>
This commit is contained in:
@@ -22,13 +22,15 @@ const StatusContext = createContext<StatusContextType>({
|
||||
|
||||
export const useStatus = () => useContext(StatusContext);
|
||||
|
||||
const baseUrl = process.env.NEXT_PUBLIC_BACKEND_BASE_URL || '/api/v1';
|
||||
|
||||
export function StatusProvider({ children }: { children: ReactNode }) {
|
||||
const [status, setStatus] = useState<StatusResponse | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch('/api/v1/status')
|
||||
fetch(`${baseUrl}/status`)
|
||||
.then((res) => {
|
||||
if (!res.ok) throw new Error('Failed to fetch status');
|
||||
return res.json();
|
||||
|
||||
@@ -17,7 +17,7 @@ interface LoadUserResponse {
|
||||
}
|
||||
|
||||
export class UserConfigAPI {
|
||||
private static BASE_URL = '/api/v1';
|
||||
private static BASE_URL = process.env.NEXT_PUBLIC_BACKEND_BASE_URL || '/api/v1';
|
||||
|
||||
static async loadConfig(
|
||||
uuid: string,
|
||||
|
||||
@@ -41,6 +41,12 @@ app.use(loggerMiddleware);
|
||||
app.use(express.json());
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
// Allow all origins in development for easier testing
|
||||
if (Env.NODE_ENV === 'development') {
|
||||
logger.info('CORS enabled for all origins in development');
|
||||
app.use(corsMiddleware);
|
||||
}
|
||||
|
||||
// API Routes
|
||||
const apiRouter = express.Router();
|
||||
apiRouter.use('/user', userApi);
|
||||
|
||||
Reference in New Issue
Block a user