Add standalone API proxy via curl (bypasses WAF TLS fingerprinting)
Modern.js SSR intercepts all routes before any Express middleware, so the API proxy runs as a separate Express server on port 8080. Modern.js runs on 8081. The proxy uses curl subprocesses which go through the system HTTPS proxy (GOST) with a proper TLS fingerprint that the Aeroflot WAF accepts. Usage: node scripts/dev-server.mjs (replaces pnpm dev for full-stack) Also: remove stray e2e-angular test directory, fix env default to same-origin /api.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Mock Angular API endpoints that are required for the app to bootstrap.
|
||||
* The upstream Aeroflot API may be unavailable (403), so we provide
|
||||
* minimal valid responses to allow the Angular app to render.
|
||||
*/
|
||||
export async function mockAngularAPIs(page: Page): Promise<void> {
|
||||
await page.route('**/api/appSettings', (route) => {
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({
|
||||
showDebugVersion: 'False',
|
||||
uiOptions: {
|
||||
filter: {
|
||||
onlineboard: { searchFrom: '2d', searchTo: '2d' },
|
||||
schedule: { searchFrom: '30d', searchTo: '30d' },
|
||||
},
|
||||
buttons: {
|
||||
flightStatus: { availableFrom: '24h' },
|
||||
buyTicket: { period: { min: '2h', max: '72h' } },
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route('**/api/Requests/*/getpopular', (route) => {
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify([
|
||||
{ requestType: 'FlightNumber', carrierCode: 'SU', flightNumber: '0654' },
|
||||
{ requestType: 'Route', departureCity: 'LED', arrivalCity: 'KRR' },
|
||||
{ requestType: 'Route', departureCity: 'VKO', arrivalCity: 'KUF' },
|
||||
{ requestType: 'Arrival', arrivalCity: 'VKO' },
|
||||
]),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route('**/api/dictionary/**', (route) => {
|
||||
route.fulfill({ status: 200, contentType: 'application/json', body: '[]' });
|
||||
});
|
||||
|
||||
await page.route('**/api/version', (route) => {
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: '{"version":"1.0"}',
|
||||
});
|
||||
});
|
||||
|
||||
// Block external calls to avoid CORS errors
|
||||
await page.route('**/*.aeroflot.ru/**', (route) => route.abort());
|
||||
}
|
||||
Reference in New Issue
Block a user