Problem Description
The application is currently deployed using Expo (Web) and hosted on GitHub Pages. This architecture creates a specific security challenge:
- Static Hosting Limitation: Unlike server-side rendered applications, GitHub Pages is purely static and cannot hide secrets or proxy requests.
- Exposure of Endpoints: The backend API URL and any associated Keys are embedded in the JavaScript bundle.
- Unauthorized Access: Without a middle layer, malicious actors can easily identify endpoints and perform unauthorized requests or scraping.
Proposed Solution
Implement a multi-layered security strategy in the NestJS Backend:
- Strict CORS: Accept requests only from
https://nootraappdeldolar.jodaz.xyz and authorized origins.
- Multi-Tier API Key System:
- Tier 1 (Public): For the GitHub Pages site, restricted by CORS and tight Rate Limits.
- Tier 2 (Authorized): For third-party server-to-server integrations with higher quotas.
- Throttling: Use
@nestjs/throttler to limit requests based on IP and API Key.
- WAF Layer: Integration with Cloudflare for DDoS protection.
Implementation Steps
Problem Description
The application is currently deployed using Expo (Web) and hosted on GitHub Pages. This architecture creates a specific security challenge:
Proposed Solution
Implement a multi-layered security strategy in the NestJS Backend:
https://nootraappdeldolar.jodaz.xyzand authorized origins.@nestjs/throttlerto limit requests based on IP and API Key.Implementation Steps
main.tswith strict CORS.@nestjs/throttler.ApiKeyGuardin a newAuthModule.X-API-KEYheader.