diff --git a/.env.example b/.env.example index fab5202..b93a650 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,12 @@ # API Configuration VITE_API_URL=http://141.196.166.241:8003 +# Vercel Deployment Configuration +NEXT_PUBLIC_ALLOWED_HOSTS=141.196.166.241 +NEXT_PUBLIC_VERCEL_URL=${VERCEL_URL} +NODE_ENV=production + +# CORS Configuration +CORS_ORIGIN=* + # Add other environment variables as needed \ No newline at end of file diff --git a/README.md b/README.md index 5dcfb62..650daf5 100644 --- a/README.md +++ b/README.md @@ -58,18 +58,6 @@ npm run preview - Resource Distribution Visualization - System Maintenance -## API Configuration - -The application connects to an API server at `http://141.196.166.241:8003`. Make sure this endpoint is accessible from your network. - -## Environment Variables - -No additional environment variables are required to run the application in development mode. - -## Browser Support - -The application is optimized for modern browsers that support ES6+ features. - ## Environment Configuration The application uses environment variables for configuration. To set up your environment: @@ -84,6 +72,6 @@ cp .env.example .env VITE_API_URL=http://your-api-server:port ``` -The following environment variables are available: +## Browser Support -- `VITE_API_URL`: The URL of the API server (default: http://141.196.166.241:8003) +The application is optimized for modern browsers that support ES6+ features. diff --git a/src/config/env.ts b/src/config/env.ts index 4269db2..b5b6693 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -1,6 +1,10 @@ // Environment configuration const getApiUrl = (): string => { - // Use environment variable if available, fallback to development URL + // In production (Vercel), use the proxied path + if (import.meta.env.PROD) { + return '/api'; + } + // In development, use the direct URL return import.meta.env.VITE_API_URL || 'http://141.196.166.241:8003'; }; diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..15eb441 --- /dev/null +++ b/vercel.json @@ -0,0 +1,8 @@ +{ + "rewrites": [ + { + "source": "/api/:path*", + "destination": "http://141.196.166.241:8003/:path*" + } + ] +} \ No newline at end of file