Performance: CORS configuration
CORS configuration affects the network request flow and browser security checks, impacting page load speed and interaction readiness.
app.enableCors({ origin: ['https://example.com'], credentials: true });app.enableCors({ origin: '*' });| Pattern | Network Requests | Preflight Calls | Latency Impact | Verdict |
|---|---|---|---|---|
| Allow all origins with '*' | Normal | Many preflights | Adds 50-150ms per request | [X] Bad |
| Restrict origins and enable credentials | Normal | Minimal preflights | Reduces latency by 50-150ms | [OK] Good |
app.enableCors() without parameters for default settings.app.enableCors({ origin: 'https://example.com' });app.enableCors({ origins: ['https://site1.com', 'https://site2.com'] });Pass the test and this pattern moves unknown