Add CorsRegexEnvProcessor and corresponding tests
- Implemented CorsRegexEnvProcessor to build CORS origin regex from a comma-separated host list (ALLOWED_FRONTEND_HOSTS). - Added tests for CorsRegexEnvProcessor to validate regex generation and matching behavior. - Created JSON files for AST representation of the new classes and tests.
This commit is contained in:
+9
-10
@@ -25,16 +25,16 @@ MESSENGER_TRANSPORT_DSN="redis://redis-XXXXXXXX:6379/messages"
|
||||
# This is the API host, NOT a frontend domain.
|
||||
APP_BASE_URL=https://api.nobat724.com
|
||||
|
||||
# ── Frontend domains (MANY) ──
|
||||
# Both values below are GENERATED from docker/frontend-domains.json.
|
||||
# To add/remove a city domain: edit that file, then run:
|
||||
# ddev exec php docker/gen-cors-env.php (or: php docker/gen-cors-env.php on the server)
|
||||
# and paste the new output here / into Coolify.
|
||||
|
||||
# ── Frontend domains (MANY) — CORS ──
|
||||
# فقط همین یک متغیرِ سادهٔ کامادار لازم است؛ رجکسِ CORS در PHP از روی همین ساخته میشود
|
||||
# (CorsRegexEnvProcessor → nelmio). چون این مقدار هیچ کاراکتر خاصی (`$`,`\`) ندارد، Coolify
|
||||
# آن را خراب نمیکند — برخلاف CORS_ALLOW_ORIGIN که حذف شده است.
|
||||
# افزودن/حذف دامنهٔ شهر: docker/frontend-domains.json را ویرایش کن، سپس
|
||||
# ddev exec php docker/gen-cors-env.php (یا روی سرور: php docker/gen-cors-env.php)
|
||||
# و خروجی ALLOWED_FRONTEND_HOSTS را اینجا/در Coolify جایگزین کن.
|
||||
# ⚠️ دیگر CORS_ALLOW_ORIGIN را ست نکن (استفاده نمیشود).
|
||||
ALLOWED_FRONTEND_HOSTS=ahvaz-nobat.ir,arak-nobat.ir,ardabil-nobat.ir,bandar-nobat.ir,behbahan-nobat.ir,birjand-nobat.ir,bojnord-nobat.ir,bushehr-nobat.ir,dehdasht-nobat.ir,esf-nobat.ir,golestan-nobat.ir,hamadan-nobat.ir,ilam-nobat.ir,karaj-nobat.ir,kerman-nobat.ir,kermanshah-nobat.ir,lorestan-nobat.ir,mashhad-nobat.ir,nobat724.com,qazvin-nobat.ir,qom-nobat.ir,rasht-nobat.ir,sanandaj-nobat.ir,sari-nobat.ir,semnan-nobat.ir,shiraz-nobat.ir,shkord-nobat.ir,tabriz-nobat.ir,tehran-nobat.ir,urmia-nobat.ir,yasuj-nobat.ir,yazd-nobat.ir,zahedan-nobat.ir,zanjan-nobat.ir
|
||||
|
||||
CORS_ALLOW_ORIGIN='^https://(ahvaz\-nobat\.ir|arak\-nobat\.ir|ardabil\-nobat\.ir|bandar\-nobat\.ir|behbahan\-nobat\.ir|birjand\-nobat\.ir|bojnord\-nobat\.ir|bushehr\-nobat\.ir|dehdasht\-nobat\.ir|esf\-nobat\.ir|golestan\-nobat\.ir|hamadan\-nobat\.ir|ilam\-nobat\.ir|karaj\-nobat\.ir|kerman\-nobat\.ir|kermanshah\-nobat\.ir|lorestan\-nobat\.ir|mashhad\-nobat\.ir|nobat724\.com|qazvin\-nobat\.ir|qom\-nobat\.ir|rasht\-nobat\.ir|sanandaj\-nobat\.ir|sari\-nobat\.ir|semnan\-nobat\.ir|shiraz\-nobat\.ir|shkord\-nobat\.ir|tabriz\-nobat\.ir|tehran\-nobat\.ir|urmia\-nobat\.ir|yasuj\-nobat\.ir|yazd\-nobat\.ir|zahedan\-nobat\.ir|zanjan\-nobat\.ir)$'
|
||||
|
||||
# ── Secrets (REQUIRED — set before the first deploy) ──
|
||||
APP_SECRET= # php -r "echo bin2hex(random_bytes(32));"
|
||||
JWT_PASSPHRASE= # openssl rand -hex 32 (must exist before first start: JWT keypair is generated with it)
|
||||
@@ -75,8 +75,7 @@ JWT_PASSPHRASE=...
|
||||
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
|
||||
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
|
||||
TRUSTED_PROXIES=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.1
|
||||
ALLOWED_FRONTEND_HOSTS=... # همان خروجی gen-cors-env.php
|
||||
CORS_ALLOW_ORIGIN=... # همان
|
||||
ALLOWED_FRONTEND_HOSTS=... # همان خروجی gen-cors-env.php (رجکس CORS از همین ساخته میشود)
|
||||
API_IR_BASE_URL=https://s.api.ir
|
||||
API_IR_TOKEN=...
|
||||
REFRESH_TOKEN_TTL / OTP_TTL / MAX_FILE_SIZE_BYTES / UPLOAD_DIR
|
||||
|
||||
Reference in New Issue
Block a user