Skip to content

Commit 9dd6e9d

Browse files
committed
Fix apps-rendering routes
1 parent 7c79cc6 commit 9dd6e9d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

apps-rendering/src/server/server.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ app.use('/assets', express.static(path.resolve(__dirname, '../assets')));
396396
app.use('/assets', express.static(path.resolve(__dirname, '../dist/assets')));
397397
app.use(compression());
398398

399-
app.all('*', (request, response, next) => {
399+
app.all('/{*splat}', (request, response, next) => {
400400
const start = Date.now();
401401

402402
response.once('finish', () => {
@@ -425,13 +425,13 @@ app.get('/fontSize.css', (_, res) => {
425425
To enable testing in the mobile device emulators,
426426
this route handler adds compatability with DCR's route for apps articles.
427427
The DCR route follows the pattern:
428-
/AppsArticle/https://www.theguardian.com/cities/2019/sep/13/reclaimed-lakes-and-giant-airports-how-mexico-city-might-have-looked
428+
AppsArticle/https://www.theguardian.com/food/2020/mar/15/easter-taste-test-dan-lepard-hot-cross-bun-milk-dark-chocolate-mini-eggs-bunny-sloth
429429
*/
430430
app.get(
431-
'/AppsArticle/*',
431+
'/AppsArticle/*url',
432432
express.raw(),
433433
(req, res, next) => {
434-
const contentWebUrl = req.params[0];
434+
const contentWebUrl = req.originalUrl.split('/').slice(2).join('/');
435435
const articleId = new URL(contentWebUrl).pathname;
436436
req.params = {
437437
0: articleId,
@@ -443,16 +443,13 @@ app.get(
443443
);
444444

445445
app.get(
446-
'/:edition(uk|us|au|europe|international)?/rendered-items/*',
447-
express.raw(),
448-
serveArticleGet,
449-
);
450-
app.get(
451-
'/:edition(uk|us|au|europe|international)?/*',
446+
['/:edition/rendered-items/*path', '/rendered-items/*path'],
452447
express.raw(),
453448
serveArticleGet,
454449
);
455450

451+
app.get(['/:edition/*path', '/*path'], express.raw(), serveArticleGet);
452+
456453
app.post('/article', express.raw(), serveArticlePost);
457454

458455
app.post('/editions-article', express.raw(), serveEditionsArticlePost);

0 commit comments

Comments
 (0)