Skip to content

Commit

Permalink
feat(apps): provide response for root requests to dns.angular.dev (#2193
Browse files Browse the repository at this point in the history
)

Provide a response for root requests to dns.angular.dev as a 200 response.

PR Close #2193
  • Loading branch information
josephperrott committed Jul 23, 2024
1 parent baedcbe commit 2aa7705
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions apps/functions/dns-redirecting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@ export const dnsRedirecting = functions
maxInstances: 2,
})
.https.onRequest(async (request, response) => {
/** The type of redirect to use, defaulting to a 301 permanent redirect. */
let redirectType = 301;
/** The hostname that was used for the request. */
let hostname = request.hostname;

// If a hostname is provided as a query param, use it instead. This allows us to verify redirects prior to the
// DNS records being setup. We use a 302 redirect for this as its a temporary check.
if (request.hostname === 'dns.angular.dev' && request.query['hostname']) {
hostname = request.query['hostname'] as string;
redirectType = 302;
if (request.hostname === 'dns.angular.dev') {
// If a hostname is provided as a query param, use it instead. This allows us to verify redirects prior to the
// DNS records being setup. We use a 302 redirect for this as its a temporary check.
if (request.query['hostname']) {
hostname = request.query['hostname'] as string;
redirectType = 302;
} else {
response.status(200);
response.send(
'No content available at this page, redirects will be made for requests at the registered subdomain.',
);
return;
}
}

if (hostname === 'update.angular.dev') {
Expand Down

0 comments on commit 2aa7705

Please sign in to comment.