server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
# CORS headers for all responses
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
# Handle preflight requests
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
}
# Mock login endpoint
location = /api/v1/auth/token/json {
default_type application/json;
return 200 '{"access_token": "mock_token_12345", "refresh_token": "mock_refresh_67890", "token_type": "bearer"}';
}
# Mock register endpoint
location = /api/v1/auth/register {
default_type application/json;
return 200 '{"message": "User created successfully", "user_id": "mock_user_123"}';
}
# Mock refresh token endpoint
location = /api/v1/auth/refresh {
default_type application/json;
return 200 '{"access_token": "new_mock_token_12345", "refresh_token": "new_mock_refresh_67890"}';
}
# Mock user info endpoint
location = /api/v1/auth/users/me {
default_type application/json;
return 200 '{"id": "mock_user_123", "username": "testuser", "email": "test@example.com", "full_name": "Test User"}';
}
# Mock trackers endpoint
location = /api/v1/trackers {
default_type application/json;
return 200 '[{"id": "1", "name": "GitHub Issues", "type": "github", "status": "active"}, {"id": "2", "name": "Jira Project", "type": "jira", "status": "active"}]';
}
# Mock API usage endpoint
location = /api/v1/auth/api-usage {
default_type application/json;
return 200 '{"requests_this_month": 1250, "requests_limit": 10000, "reset_date": "2024-02-01"}';
}
# Mock duplicate issues endpoint
location = /api/v1/issue-duplicates/ {
default_type application/json;
return 200 '[{"id": "1", "title": "Login button not working", "duplicate_of": "Issue #42", "confidence": 0.95}, {"id": "2", "title": "Cannot access dashboard", "duplicate_of": "Issue #38", "confidence": 0.87}]';
}
# Mock API keys endpoint
location = /api/v1/auth/api-keys {
default_type application/json;
return 200 '[{"id": "key_1", "name": "Production API Key", "created_at": "2024-01-15T10:30:00Z", "last_used_at": "2024-01-20T14:22:00Z", "expires_at": null}]';
}
# Mock AI models endpoint
location = /api/v1/ai-models {
default_type application/json;
return 200 '[{"id": "model_1", "name": "GPT-4", "provider_name": "OpenAI", "model_name": "gpt-4", "is_default": true, "created_at": "2024-01-10T09:00:00Z"}]';
}
# Fallback for other API endpoints
location /api/ {
default_type application/json;
return 200 '{"message": "Mock API endpoint", "endpoint": "$uri", "method": "$request_method"}';
}
# Health check
location /health {
return 200 "Mock API is healthy\n";
add_header Content-Type text/plain;
}
}