|
@ -2,33 +2,30 @@ |
|
|
|
|
|
|
|
|
**Author**: Matthew Raymer |
|
|
**Author**: Matthew Raymer |
|
|
**Date**: 2025-01-27 |
|
|
**Date**: 2025-01-27 |
|
|
**Status**: ✅ **COMPLETE** - Domain configuration system implemented |
|
|
**Status**: ✅ **UPDATED** - Simplified to use APP_SERVER for all functionality |
|
|
|
|
|
|
|
|
## Overview |
|
|
## Overview |
|
|
|
|
|
|
|
|
TimeSafari uses a centralized domain configuration system to ensure consistent |
|
|
TimeSafari uses a centralized domain configuration system to ensure consistent |
|
|
URL generation across all environments. This system prevents localhost URLs from |
|
|
URL generation across all environments. This system provides a single point of |
|
|
appearing in shared links during development and provides a single point of |
|
|
control for domain changes and uses environment-specific configuration for all |
|
|
control for domain changes. |
|
|
functionality including sharing. |
|
|
|
|
|
|
|
|
## Problem Solved |
|
|
## Problem Solved |
|
|
|
|
|
|
|
|
### Issue: Localhost URLs in Shared Links |
|
|
### Issue: Inconsistent Domain Usage |
|
|
|
|
|
|
|
|
Previously, copy link buttons and deep link generation used the environment- |
|
|
Previously, the system used separate constants for different types of URLs: |
|
|
specific `APP_SERVER` constant, which resulted in: |
|
|
|
|
|
|
|
|
|
|
|
- **Development**: `http://localhost:8080/deep-link/claim/123` |
|
|
- **Internal Operations**: Used `APP_SERVER` (environment-specific) |
|
|
- **Test**: `https://test.timesafari.app/deep-link/claim/123` |
|
|
- **Sharing**: Used separate constants (removed) |
|
|
- **Production**: `https://timesafari.app/deep-link/claim/123` |
|
|
|
|
|
|
|
|
|
|
|
This caused problems when users in development mode shared links, as the |
|
|
This created complexity and confusion about when to use which constant. |
|
|
localhost URLs wouldn't work for other users. |
|
|
|
|
|
|
|
|
|
|
|
### Solution: Production Domain for Sharing |
|
|
### Solution: Unified Domain Configuration |
|
|
|
|
|
|
|
|
All sharing functionality now uses the `PROD_SHARE_DOMAIN` constant, which |
|
|
All functionality now uses the `APP_SERVER` constant, which provides |
|
|
always points to the production domain regardless of the current environment. |
|
|
environment-specific URLs that can be configured per environment. |
|
|
|
|
|
|
|
|
## Implementation |
|
|
## Implementation |
|
|
|
|
|
|
|
@ -43,27 +40,28 @@ export enum AppString { |
|
|
// ... other constants ... |
|
|
// ... other constants ... |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Production domain for sharing links (always use production URL for sharing) |
|
|
// Environment-specific server URL for all functionality |
|
|
export const PROD_SHARE_DOMAIN = AppString.PROD_PUSH_SERVER; |
|
|
export const APP_SERVER = |
|
|
|
|
|
import.meta.env.VITE_APP_SERVER || "https://timesafari.app"; |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
### Usage Pattern |
|
|
### Usage Pattern |
|
|
|
|
|
|
|
|
All components that generate shareable links follow this pattern: |
|
|
All components that generate URLs follow this pattern: |
|
|
|
|
|
|
|
|
```typescript |
|
|
```typescript |
|
|
import { PROD_SHARE_DOMAIN } from "@/constants/app"; |
|
|
import { APP_SERVER } from "@/constants/app"; |
|
|
|
|
|
|
|
|
// In component class |
|
|
// In component class |
|
|
PROD_SHARE_DOMAIN = PROD_SHARE_DOMAIN; |
|
|
APP_SERVER = APP_SERVER; |
|
|
|
|
|
|
|
|
// In methods |
|
|
// In methods |
|
|
const deepLink = `${PROD_SHARE_DOMAIN}/deep-link/claim/${claimId}`; |
|
|
const deepLink = `${APP_SERVER}/deep-link/claim/${claimId}`; |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
### Components Updated |
|
|
### Components Updated |
|
|
|
|
|
|
|
|
The following components and services were updated to use `PROD_SHARE_DOMAIN`: |
|
|
The following components and services use `APP_SERVER`: |
|
|
|
|
|
|
|
|
#### Views |
|
|
#### Views |
|
|
- `ClaimView.vue` - Claim and certificate links |
|
|
- `ClaimView.vue` - Claim and certificate links |
|
@ -82,17 +80,28 @@ The following components and services were updated to use `PROD_SHARE_DOMAIN`: |
|
|
|
|
|
|
|
|
## Configuration Management |
|
|
## Configuration Management |
|
|
|
|
|
|
|
|
### Changing the Production Domain |
|
|
### Environment-Specific Configuration |
|
|
|
|
|
|
|
|
To change the production domain for all sharing functionality: |
|
|
The system uses environment variables to configure domains: |
|
|
|
|
|
|
|
|
1. **Update the constant** in `src/constants/app.ts`: |
|
|
```bash |
|
|
```typescript |
|
|
# Development |
|
|
export enum AppString { |
|
|
VITE_APP_SERVER=http://localhost:8080 |
|
|
// ... other constants ... |
|
|
|
|
|
PROD_PUSH_SERVER = "https://your-new-domain.com", |
|
|
# Test |
|
|
// ... other constants ... |
|
|
VITE_APP_SERVER=https://test.timesafari.app |
|
|
} |
|
|
|
|
|
|
|
|
# Production |
|
|
|
|
|
VITE_APP_SERVER=https://timesafari.app |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
### Changing the Domain |
|
|
|
|
|
|
|
|
|
|
|
To change the domain for all functionality: |
|
|
|
|
|
|
|
|
|
|
|
1. **Update environment variables** for the target environment: |
|
|
|
|
|
```bash |
|
|
|
|
|
VITE_APP_SERVER=https://your-new-domain.com |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
2. **Rebuild the application** for all platforms: |
|
|
2. **Rebuild the application** for all platforms: |
|
@ -102,46 +111,32 @@ To change the production domain for all sharing functionality: |
|
|
npm run build:electron |
|
|
npm run build:electron |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
### Environment-Specific Configuration |
|
|
## Benefits |
|
|
|
|
|
|
|
|
The system maintains environment-specific configuration for internal operations |
|
|
|
|
|
while using production domains for sharing: |
|
|
|
|
|
|
|
|
|
|
|
```typescript |
|
|
|
|
|
// Internal operations use environment-specific URLs |
|
|
|
|
|
export const APP_SERVER = |
|
|
|
|
|
import.meta.env.VITE_APP_SERVER || "https://timesafari.app"; |
|
|
|
|
|
|
|
|
|
|
|
// Sharing always uses production URLs |
|
|
### ✅ Simplified Configuration |
|
|
export const PROD_SHARE_DOMAIN = AppString.PROD_PUSH_SERVER; |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
## Benefits |
|
|
- Single constant for all URL generation |
|
|
|
|
|
- No confusion about which constant to use |
|
|
|
|
|
- Consistent behavior across all functionality |
|
|
|
|
|
|
|
|
### ✅ Consistent User Experience |
|
|
### ✅ Environment Flexibility |
|
|
|
|
|
|
|
|
- All shared links work for all users regardless of environment |
|
|
- Easy to configure different domains per environment |
|
|
- No more broken localhost links in development |
|
|
- Support for development, test, and production environments |
|
|
- Consistent behavior across all platforms |
|
|
- Environment-specific sharing URLs when needed |
|
|
|
|
|
|
|
|
### ✅ Maintainability |
|
|
### ✅ Maintainability |
|
|
|
|
|
|
|
|
- Single source of truth for production domain |
|
|
- Single source of truth for domain configuration |
|
|
- Easy to change domain across entire application |
|
|
- Easy to change domain across entire application |
|
|
- Clear separation between internal and sharing URLs |
|
|
- Clear pattern for implementing new URL functionality |
|
|
|
|
|
|
|
|
### ✅ Developer Experience |
|
|
### ✅ Developer Experience |
|
|
|
|
|
|
|
|
- No need to remember which environment URLs work for sharing |
|
|
- Simple, consistent pattern for URL generation |
|
|
- Clear pattern for implementing new sharing functionality |
|
|
- Clear documentation and examples |
|
|
- Type-safe configuration with TypeScript |
|
|
- Type-safe configuration with TypeScript |
|
|
|
|
|
|
|
|
### ✅ Security |
|
|
|
|
|
|
|
|
|
|
|
- No accidental exposure of internal development URLs |
|
|
|
|
|
- Controlled domain configuration |
|
|
|
|
|
- Clear audit trail for domain changes |
|
|
|
|
|
|
|
|
|
|
|
## Testing |
|
|
## Testing |
|
|
|
|
|
|
|
|
### Manual Testing |
|
|
### Manual Testing |
|
@ -150,7 +145,7 @@ export const PROD_SHARE_DOMAIN = AppString.PROD_PUSH_SERVER; |
|
|
```bash |
|
|
```bash |
|
|
npm run dev |
|
|
npm run dev |
|
|
# Navigate to any page with copy link buttons |
|
|
# Navigate to any page with copy link buttons |
|
|
# Verify links use production domain, not localhost |
|
|
# Verify links use configured domain |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
2. **Production Build**: |
|
|
2. **Production Build**: |
|
@ -164,27 +159,19 @@ export const PROD_SHARE_DOMAIN = AppString.PROD_PUSH_SERVER; |
|
|
|
|
|
|
|
|
The implementation includes comprehensive linting to ensure: |
|
|
The implementation includes comprehensive linting to ensure: |
|
|
|
|
|
|
|
|
- All components properly import `PROD_SHARE_DOMAIN` |
|
|
- All components properly import `APP_SERVER` |
|
|
- No hardcoded URLs in sharing functionality |
|
|
- No hardcoded URLs in functionality |
|
|
- Consistent usage patterns across the codebase |
|
|
- Consistent usage patterns across the codebase |
|
|
|
|
|
|
|
|
## Migration Notes |
|
|
## Implementation Pattern |
|
|
|
|
|
|
|
|
### Before Implementation |
|
|
|
|
|
|
|
|
|
|
|
```typescript |
|
|
|
|
|
// ❌ Hardcoded URLs |
|
|
|
|
|
const deepLink = "https://timesafari.app/deep-link/claim/123"; |
|
|
|
|
|
|
|
|
|
|
|
// ❌ Environment-specific URLs |
|
|
|
|
|
const deepLink = `${APP_SERVER}/deep-link/claim/123`; |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
### After Implementation |
|
|
### Current Approach |
|
|
|
|
|
|
|
|
```typescript |
|
|
```typescript |
|
|
// ✅ Configurable production URLs |
|
|
// ✅ Single constant for all functionality |
|
|
const deepLink = `${PROD_SHARE_DOMAIN}/deep-link/claim/123`; |
|
|
import { APP_SERVER } from "@/constants/app"; |
|
|
|
|
|
const shareLink = `${APP_SERVER}/deep-link/claim/123`; |
|
|
|
|
|
const apiUrl = `${APP_SERVER}/api/claim/123`; |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
## Future Enhancements |
|
|
## Future Enhancements |
|
@ -208,6 +195,7 @@ const deepLink = `${PROD_SHARE_DOMAIN}/deep-link/claim/123`; |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
3. **Platform-Specific Domains**: |
|
|
3. **Platform-Specific Domains**: |
|
|
|
|
|
|
|
|
```typescript |
|
|
```typescript |
|
|
export const getPlatformShareDomain = () => { |
|
|
export const getPlatformShareDomain = () => { |
|
|
const platform = process.env.VITE_PLATFORM; |
|
|
const platform = process.env.VITE_PLATFORM; |
|
@ -229,5 +217,5 @@ const deepLink = `${PROD_SHARE_DOMAIN}/deep-link/claim/123`; |
|
|
--- |
|
|
--- |
|
|
|
|
|
|
|
|
**Last Updated**: 2025-01-27 |
|
|
**Last Updated**: 2025-01-27 |
|
|
**Version**: 1.0 |
|
|
**Version**: 2.0 |
|
|
**Maintainer**: Matthew Raymer |
|
|
**Maintainer**: Matthew Raymer |