This commit is contained in:
Dmitry 2025-11-19 23:10:22 +03:00
parent fd447d4517
commit 11be956735
11 changed files with 25 additions and 26 deletions

View file

@ -8,7 +8,7 @@ mixin Api {
? 'http://localhost:8000' ? 'http://localhost:8000'
: !ADMIN_BUILD || (globalSharedPreferences.getBool('env') ?? true) : !ADMIN_BUILD || (globalSharedPreferences.getBool('env') ?? true)
//prod //prod
? 'https://1592725-cf88967.twc1.net:8080' // 'https://89.19.210.178:8080' //FirebaseRepository.appConfig.path ? 'https://api.mnemo-cards.online:8080' // Production API endpoint
: deviceInfo!.isPhysicalDevice : deviceInfo!.isPhysicalDevice
//device to localhost //device to localhost
? 'https://192.168.31.193:8080' ? 'https://192.168.31.193:8080'

View file

@ -99,11 +99,11 @@ flutter run -d chrome --web-port=8080
Для production версии: Для production версии:
1. **Backend** уже настроен с правильными CORS настройками ✅ 1. **Backend** уже настроен с правильными CORS настройками ✅
2. **Frontend** использует `api.memo-cards.online` ✅ 2. **Frontend** использует `api.mnemo-cards.online` ✅
3. **Nginx** настроен без конфликтующих COEP/COOP headers ✅ 3. **Nginx** настроен без конфликтующих COEP/COOP headers ✅
Текущая конфигурация позволяет: Текущая конфигурация позволяет:
- ✅ Запросы с `memo-cards.online` на `api.memo-cards.online` - ✅ Запросы с `memo-cards.online` на `api.mnemo-cards.online`
- ✅ Все необходимые HTTP методы и headers - ✅ Все необходимые HTTP методы и headers
- ✅ Preflight OPTIONS запросы - ✅ Preflight OPTIONS запросы

View file

@ -1614,7 +1614,7 @@ Enable mnemo_cards_web_v2 to communicate with the same backend as the main mnemo
#### 1. API Configuration ✅ #### 1. API Configuration ✅
- Changed baseUrl: `http://localhost:8080` → `http://localhost:8000` - Changed baseUrl: `http://localhost:8080` → `http://localhost:8000`
- Matches main app web version - Matches main app web version
- Production URL: `https://1592725-cf88967.twc1.net:8080` - Production URL: `https://api.mnemo-cards.online:8081`
- Changed appVersion: `2.0.0` → `1.1.0` - Changed appVersion: `2.0.0` → `1.1.0`
- Required for TokenGenerator compatibility - Required for TokenGenerator compatibility
- Enables proper request token generation - Enables proper request token generation

View file

@ -47,7 +47,7 @@ cd deploy
All deployment settings are in `tools/deploy/web-app/config.sh`: All deployment settings are in `tools/deploy/web-app/config.sh`:
- Server IP: `147.45.152.129` - Server IP: `147.45.152.129`
- Main domain: `memo-cards.online` - Main domain: `memo-cards.online`
- API URL: `https://api.memo-cards.online:8081` - API URL: `https://api.mnemo-cards.online` (nginx reverse proxy on port 443)
## 📝 Project-Specific Files ## 📝 Project-Specific Files

View file

@ -5,8 +5,8 @@
@Deprecated('Use ApiConfigV2 instead') @Deprecated('Use ApiConfigV2 instead')
class ApiConfig { class ApiConfig {
/// Base URL for the API /// Base URL for the API
/// For web, we use localhost:8000 (same as main app web version) /// For production: https://api.mnemo-cards.online:8081
/// For production deploy, change to: 'https://1592725-cf88967.twc1.net:8080' /// For local development: http://localhost:8000
static String get baseUrl => const String.fromEnvironment( static String get baseUrl => const String.fromEnvironment(
'API_BASE_URL', 'API_BASE_URL',
defaultValue: 'http://localhost:8000', // Development server defaultValue: 'http://localhost:8000', // Development server

View file

@ -12,8 +12,7 @@ class ApiConfigV2 {
static String get baseUrl { static String get baseUrl {
final base = const String.fromEnvironment( final base = const String.fromEnvironment(
'API_BASE_URL', 'API_BASE_URL',
// defaultValue: 'http://localhost:8000', defaultValue: 'https://api.mnemo-cards.online',
defaultValue: 'https://1592725-cf88967.twc1.net:8081',
); );
return '$base/api/v2'; return '$base/api/v2';
} }

View file

@ -74,7 +74,7 @@ cd web-app
- `SERVER_IP` - IP сервера (147.45.152.129) - `SERVER_IP` - IP сервера (147.45.152.129)
- `DOMAIN` - домен веб приложения (memo-cards.online) - `DOMAIN` - домен веб приложения (memo-cards.online)
- `API_BASE_URL` - URL API (https://api.memo-cards.online:8081) - `API_BASE_URL` - URL API (https://api.mnemo-cards.online:8081)
### SSH доступ ### SSH доступ
@ -103,7 +103,7 @@ cd web-app
Автоматически получаются сертификаты Let's Encrypt для: Автоматически получаются сертификаты Let's Encrypt для:
- `memo-cards.online` (web app) - `memo-cards.online` (web app)
- `api.memo-cards.online` (backend API) - `api.mnemo-cards.online` (backend API)
- `vscode.mnemo-cards.online` (VSCode Server) - `vscode.mnemo-cards.online` (VSCode Server)
- `code.mnemo-cards.online` (Forgejo Git Server) - `code.mnemo-cards.online` (Forgejo Git Server)

View file

@ -23,7 +23,7 @@ rm server_build.exe
cat > /tmp/api-https-only << 'EOF' cat > /tmp/api-https-only << 'EOF'
server { server {
listen 80; listen 80;
server_name api.memo-cards.online; server_name api.mnemo-cards.online;
# Serve ACME challenge for Let's Encrypt # Serve ACME challenge for Let's Encrypt
location /.well-known/acme-challenge/ { location /.well-known/acme-challenge/ {
@ -39,11 +39,11 @@ server {
server { server {
listen 443 ssl http2; listen 443 ssl http2;
server_name api.memo-cards.online; server_name api.mnemo-cards.online;
# SSL configuration - Let's Encrypt # SSL configuration - Let's Encrypt
ssl_certificate /etc/letsencrypt/live/api.memo-cards.online/fullchain.pem; ssl_certificate /etc/letsencrypt/live/api.mnemo-cards.online/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.memo-cards.online/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/api.mnemo-cards.online/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3; ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384; ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off; ssl_prefer_server_ciphers off;
@ -76,10 +76,10 @@ sudo cp /tmp/api-https-only /etc/nginx/sites-available/api
sudo nginx -t && sudo systemctl reload nginx sudo nginx -t && sudo systemctl reload nginx
# Проверяем наличие Let's Encrypt сертификатов для HTTPS-only режима # Проверяем наличие Let's Encrypt сертификатов для HTTPS-only режима
if [ -d "/etc/letsencrypt/live/api.memo-cards.online" ] && [ -f "/etc/letsencrypt/live/api.memo-cards.online/fullchain.pem" ]; then if [ -d "/etc/letsencrypt/live/api.mnemo-cards.online" ] && [ -f "/etc/letsencrypt/live/api.mnemo-cards.online/fullchain.pem" ]; then
echo "✅ Let's Encrypt сертификаты найдены. Запускаем в HTTPS-only режиме" echo "✅ Let's Encrypt сертификаты найдены. Запускаем в HTTPS-only режиме"
# Обновляем systemd сервис для HTTPS-only режима # Обновляем systemd сервис для HTTPS-only режима
sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8443|' /etc/systemd/system/mnemo_cards_server.service sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --certs /etc/letsencrypt/live/api.mnemo-cards.online -a 0.0.0.0 -p 8443|' /etc/systemd/system/mnemo_cards_server.service
else else
echo "⚠️ Let's Encrypt сертификаты не найдены. Пытаемся создать с помощью webroot режима..." echo "⚠️ Let's Encrypt сертификаты не найдены. Пытаемся создать с помощью webroot режима..."
@ -89,11 +89,11 @@ else
# Пытаемся получить Let's Encrypt сертификат через webroot # Пытаемся получить Let's Encrypt сертификат через webroot
echo "🔐 Получаем Let's Encrypt сертификат через webroot для домена api.memo-cards.online..." echo "🔐 Получаем Let's Encrypt сертификат через webroot для домена api.memo-cards.online..."
if sudo certbot certonly --webroot -w /var/www/html -d api.memo-cards.online --non-interactive --agree-tos --email admin@api.memo-cards.online; then if sudo certbot certonly --webroot -w /var/www/html -d api.memo-cards.online --non-interactive --agree-tos --email admin@api.mnemo-cards.online; then
echo "✅ Let's Encrypt сертификат успешно создан через webroot!" echo "✅ Let's Encrypt сертификат успешно создан через webroot!"
echo "🚀 Запускаем в HTTPS-only режиме" echo "🚀 Запускаем в HTTPS-only режиме"
# Обновляем systemd сервис для HTTPS-only режима # Обновляем systemd сервис для HTTPS-only режима
sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8443|' /etc/systemd/system/mnemo_cards_server.service sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --certs /etc/letsencrypt/live/api.mnemo-cards.online -a 0.0.0.0 -p 8443|' /etc/systemd/system/mnemo_cards_server.service
else else
echo "❌ Не удалось создать Let's Encrypt сертификат через webroot" echo "❌ Не удалось создать Let's Encrypt сертификат через webroot"
echo "💡 Убедитесь, что:" echo "💡 Убедитесь, что:"

View file

@ -31,9 +31,9 @@ sudo cp server_build.exe server.exe
rm server_build.exe rm server_build.exe
# Check certificates and configure mode # Check certificates and configure mode
if [ -d "/etc/letsencrypt/live/api.memo-cards.online" ]; then if [ -d "/etc/letsencrypt/live/api.mnemo-cards.online" ]; then
echo "✅ Let's Encrypt certificates found. Configuring dual mode..." echo "✅ Let's Encrypt certificates found. Configuring dual mode..."
sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --dual --certs /etc/letsencrypt/live/api.memo-cards.online -a 0.0.0.0 -p 8081|' /etc/systemd/system/mnemo_cards_server.service sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe --dual --certs /etc/letsencrypt/live/api.mnemo-cards.online -a 0.0.0.0 -p 8081|' /etc/systemd/system/mnemo_cards_server.service
else else
echo "⚠️ No certificates found. Configuring HTTP mode..." echo "⚠️ No certificates found. Configuring HTTP mode..."
sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe -a 0.0.0.0 -p 8081|' /etc/systemd/system/mnemo_cards_server.service sudo sed -i 's|ExecStart=/root/mnemo_cards_backend/server.exe.*|ExecStart=/root/mnemo_cards_backend/server.exe -a 0.0.0.0 -p 8081|' /etc/systemd/system/mnemo_cards_server.service

View file

@ -106,6 +106,6 @@ echo " - code-server: 127.0.0.1:8443 (VSCode)"
echo " - backend: 0.0.0.0:8081 (API)" echo " - backend: 0.0.0.0:8081 (API)"
echo "" echo ""
echo "🌐 URLs:" echo "🌐 URLs:"
echo " - API: https://api.memo-cards.online:8081/" echo " - API: https://api.mnemo-cards.online:8081/"
echo " - VSCode: https://vscode.mnemo-cards.online/" echo " - VSCode: https://vscode.mnemo-cards.online/"

View file

@ -36,10 +36,10 @@ export NGINX_ENABLED="/etc/nginx/sites-enabled/$APP_NAME"
# API CONFIGURATION # API CONFIGURATION
# ============================================================================= # =============================================================================
# API endpoints # API endpoints (via nginx reverse proxy on port 443)
export API_BASE_URL="https://api.memo-cards.online:8444" export API_BASE_URL="https://api.mnemo-cards.online"
#export API_BASE_URL_DEV="http://localhost:8000" #export API_BASE_URL_DEV="http://localhost:8000"
export API_BASE_URL_DEV="https://api.memo-cards.online:8443" export API_BASE_URL_DEV="https://api.mnemo-cards.online"
# ============================================================================= # =============================================================================
# SSL CONFIGURATION # SSL CONFIGURATION
@ -114,7 +114,7 @@ export FIREWALL_ALLOW_SSH="ssh"
export CRON_RENEWAL_TIMES="0 12 * * * 0 0 * * *" export CRON_RENEWAL_TIMES="0 12 * * * 0 0 * * *"
export CRON_RENEWAL_COMMAND="certbot renew --quiet --post-hook \"systemctl reload nginx\" --cert-name memo-cards.online" export CRON_RENEWAL_COMMAND="certbot renew --quiet --post-hook \"systemctl reload nginx\" --cert-name memo-cards.online"
export CRON_API_RENEWAL_COMMAND="certbot renew --quiet --cert-name api.memo-cards.online" export CRON_API_RENEWAL_COMMAND="certbot renew --quiet --cert-name api.mnemo-cards.online"
export CRON_FORGEJO_RENEWAL_COMMAND="certbot renew --quiet --cert-name code.mnemo-cards.online" export CRON_FORGEJO_RENEWAL_COMMAND="certbot renew --quiet --cert-name code.mnemo-cards.online"
# ============================================================================= # =============================================================================