in src/server/api/ampEpicRouter.ts [181:229]
currencySymbol: getLocalCurrencySymbol(countryCode),
}
: false,
};
res.setHeader('Content-Type', 'application/json');
res.setHeader('Cache-Control', 'private, no-store');
res.setHeader('Surrogate-Control', 'max-age=0');
res.json({ ...epic, ...ampState });
} catch (error) {
next(error);
}
},
);
router.get(
'/epic_view', // IMPORTANT: do not change this route!
cors({
origin: [
'https://amp-theguardian-com.cdn.ampproject.org',
'https://amp.theguardian.com',
'http://localhost:3030',
'https://amp.code.dev-theguardian.com',
],
credentials: true,
allowedHeaders: ['x-gu-geoip-country-code'],
}),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
try {
res.setHeader('Cache-Control', 'private, no-store');
res.setHeader('Surrogate-Control', 'max-age=0');
const countryCode = req.header('X-GU-GeoIP-Country-Code');
const ampVariantAssignments = getAmpVariantAssignments(req);
const epic = await ampEpic(
tests.get(),
ampVariantAssignments,
tickerData,
countryCode,
);
const campaignCode = buildAmpEpicCampaignCode(epic.testName, epic.variantName);
const { viewId, ampViewId, browserIdCookie, browserId } = req.query;
const browserIdQuery =
browserIdCookie && browserId ? `&${browserIdCookie}=${browserId}` : '';
const ophanComponentEvent: ComponentEvent = {
component: {