fix(app): ensure api baseURL resolves properly during SSR build
Deploy Canina / deploy (push) Successful in 2m50s
Deploy Canina / deploy (push) Successful in 2m50s
This commit is contained in:
1 parent
b161ecf815
commit
5c13dd2f29
1 file changed
+9
-1
@@ -2,7 +2,15 @@ import axios from 'axios';
|
||||
import { toast } from 'sonner';
|
||||
import { useUserStore } from '../store/userStore';
|
||||
|
||||
const baseURL = process.env.NEXT_PUBLIC_API_URL || (process.env.NODE_ENV === 'development' ? 'http://localhost:4001/api' : '/api');
|
||||
const getBaseURL = () => {
|
||||
if (process.env.NEXT_PUBLIC_API_URL) return process.env.NEXT_PUBLIC_API_URL;
|
||||
if (typeof window === 'undefined') {
|
||||
return 'http://127.0.0.1:4001/api';
|
||||
}
|
||||
return process.env.NODE_ENV === 'development' ? 'http://localhost:4001/api' : '/api';
|
||||
};
|
||||
|
||||
const baseURL = getBaseURL();
|
||||
|
||||
export interface ApiErrorPayload {
|
||||
success: boolean;
|
||||
|
||||
Reference in new issue
Block a user