Skip to content

Commit a4538b2

Browse files
committed
fix(apps): add additional logging of request and correct replacement of material.angular.io subdomains (#2756)
The subdomains attr on the request object is actually in reverse order of the subdomains as they are made in the request, because of this we simply put the subdomains back in the original order replacing only the hostname with angular.dev instead of angular.io. PR Close #2756
1 parent 6b8b45c commit a4538b2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

apps/functions/dns-redirecting/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const dnsRedirecting = functions.https.onRequest(
88
maxInstances: 2,
99
},
1010
async (request, response) => {
11+
console.log(`Request made at: ${request.protocol}://${request.hostname}${request.originalUrl}`);
1112
/** The type of redirect to use, defaulting to a 301 permanent redirect. */
1213
let redirectType = 301;
1314
/** The hostname that was used for the request. */
@@ -45,7 +46,7 @@ export const dnsRedirecting = functions.https.onRequest(
4546
} else if (hostname.endsWith('.material.angular.io')) {
4647
response.redirect(
4748
redirectType,
48-
`https://${request.subdomains[0]}.material.angular.dev${request.originalUrl}`,
49+
`https://${request.subdomains.reverse().join('.')}.angular.dev${request.originalUrl}`,
4950
);
5051
} else {
5152
// If no redirect is matched, we return a failure message

0 commit comments

Comments
 (0)