Skip to content

Commit ac6d163

Browse files
committed
fix(apps): respond to request for m.aio/assets/versions.json directly (#2796)
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. PR Close #2796
1 parent 057595f commit ac6d163

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
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(

0 commit comments

Comments
 (0)