Skip to content

Commit c17d294

Browse files
committed
fix(apps): respond to request for m.aio/assets/versions.json directly
Rather than respond with a redirect for the versions information on m.aio, respond with the actual JSON string that would be responded at the destination url to prevent CORS issues.
1 parent 43b8195 commit c17d294

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

apps/functions/dns-redirecting/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as functions from 'firebase-functions';
22

33
export const dnsRedirecting = functions.https.onRequest(
44
{
5+
cors: true,
56
invoker: 'public',
67
timeoutSeconds: 5,
78
minInstances: 1,
@@ -42,6 +43,13 @@ export const dnsRedirecting = functions.https.onRequest(
4243
} else if (hostname === 'blog.angular.io') {
4344
response.redirect(redirectType, `https://blog.angular.dev${request.originalUrl}`);
4445
} else if (hostname === 'material.angular.io') {
46+
if (request.originalUrl === '/assets/versions.json') {
47+
const versionsData = await fetch('https://material.angular.dev/assets/versions.json').then(
48+
(r) => r.json(),
49+
);
50+
response.set('Content-Type', 'application/json').send(JSON.stringify(versionsData));
51+
return;
52+
}
4553
response.redirect(redirectType, `https://material.angular.dev${request.originalUrl}`);
4654
} else if (hostname.endsWith('.material.angular.io')) {
4755
response.redirect(

yarn.lock

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,30 +2589,7 @@ __metadata:
25892589
languageName: node
25902590
linkType: hard
25912591

2592-
"@microsoft/api-extractor@npm:7.52.8":
2593-
version: 7.52.8
2594-
resolution: "@microsoft/api-extractor@npm:7.52.8"
2595-
dependencies:
2596-
"@microsoft/api-extractor-model": "npm:7.30.6"
2597-
"@microsoft/tsdoc": "npm:~0.15.1"
2598-
"@microsoft/tsdoc-config": "npm:~0.17.1"
2599-
"@rushstack/node-core-library": "npm:5.13.1"
2600-
"@rushstack/rig-package": "npm:0.5.3"
2601-
"@rushstack/terminal": "npm:0.15.3"
2602-
"@rushstack/ts-command-line": "npm:5.0.1"
2603-
lodash: "npm:~4.17.15"
2604-
minimatch: "npm:~3.0.3"
2605-
resolve: "npm:~1.22.1"
2606-
semver: "npm:~7.5.4"
2607-
source-map: "npm:~0.6.1"
2608-
typescript: "npm:5.8.2"
2609-
bin:
2610-
api-extractor: bin/api-extractor
2611-
checksum: 10c0/42f4335ebf27c7fa819a858378062d774e130dda109f001825d49fd284430c62ea9eb703a8c49a9dd8e3a607bbf19ba4457548353282673e7429e0e6d01b325b
2612-
languageName: node
2613-
linkType: hard
2614-
2615-
"@microsoft/api-extractor@npm:^7.24.2":
2592+
"@microsoft/api-extractor@npm:7.52.8, @microsoft/api-extractor@npm:^7.24.2":
26162593
version: 7.52.8
26172594
resolution: "@microsoft/api-extractor@npm:7.52.8"
26182595
dependencies:

0 commit comments

Comments
 (0)