2025-08-15 23:03:15 +07:00
|
|
|
# Backend Configuration
|
|
|
|
|
|
|
|
|
|
## Quick Setup
|
|
|
|
|
|
|
|
|
|
If you're having issues with environment variables, you can modify the backend URL directly in the code:
|
|
|
|
|
|
|
|
|
|
### 1. Edit `lib/config.ts`
|
|
|
|
|
|
|
|
|
|
Find this line in the file:
|
|
|
|
|
```typescript
|
2025-08-15 23:16:19 +07:00
|
|
|
const BACKEND_URL = 'https://evoting-be.apskel.org' // Change this to your backend URL
|
2025-08-15 23:03:15 +07:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Change it to your actual backend URL, for example:
|
|
|
|
|
```typescript
|
|
|
|
|
const BACKEND_URL = 'http://localhost:4002' // Your backend URL
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 2. Set Auth Header
|
|
|
|
|
|
|
|
|
|
Also find this line:
|
|
|
|
|
```typescript
|
|
|
|
|
const AUTH_HEADER = '••••••' // Change this to your actual auth header
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Change it to your actual authorization header value.
|
|
|
|
|
|
|
|
|
|
### 3. Restart the Application
|
|
|
|
|
|
|
|
|
|
After making changes, restart your Next.js development server:
|
|
|
|
|
```bash
|
|
|
|
|
npm run dev
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Current Configuration
|
|
|
|
|
|
|
|
|
|
The application is currently configured to call:
|
2025-08-15 23:16:19 +07:00
|
|
|
- **Login URL**: `https://evoting-be.apskel.org/api/v1/auth/login`
|
2025-08-15 23:03:15 +07:00
|
|
|
- **Auth Header**: `••••••`
|
|
|
|
|
|
|
|
|
|
## Debug Information
|
|
|
|
|
|
|
|
|
|
Check your browser's console (F12 → Console) to see:
|
|
|
|
|
- What URL is being called
|
|
|
|
|
- Whether the auth header is set
|
|
|
|
|
- The response from the backend
|
|
|
|
|
|
|
|
|
|
## Alternative: Environment Variables
|
|
|
|
|
|
|
|
|
|
If you prefer to use environment variables, create a `.env.local` file in the root directory:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
NEXT_PUBLIC_API_BASE_URL=http://localhost:4002
|
|
|
|
|
NEXT_PUBLIC_API_AUTH_HEADER=your_actual_auth_header
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Testing
|
|
|
|
|
|
|
|
|
|
Use this curl command to test your backend:
|
|
|
|
|
```bash
|
|
|
|
|
curl --location 'http://localhost:4002/api/v1/auth/login' \
|
|
|
|
|
--header 'Content-Type: application/json' \
|
|
|
|
|
--header 'Authorization: your_actual_auth_header' \
|
|
|
|
|
--data-raw '{
|
|
|
|
|
"email": "superadmin@example.com",
|
|
|
|
|
"password": "ChangeMe!Super#123"
|
|
|
|
|
}'
|
|
|
|
|
```
|